question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Labels with spaces produce invalid type names

See original GitHub issue

With this schema:

export const RegisterAccountParams = Joi.object({
  name: Joi.string()
    .label("Company Name")
    .required(),
  phoneNumber: Joi.string()
    .label("Company Phone Number")
    .required(),
  customerEmail: Joi.string()
    .label("Customer Email")
    .required(),
  website: Joi.string()
    .label("Website")
});

this output is generated:

/**
 * This file was automatically generated by joi-to-typescript
 * Do not modify this file manually
 */

import { Customer Email, Company Name, Company Phone Number, Website } from '.';

export interface RegisterAccountParams {
  customerEmail: Customer Email;
  name: Company Name;
  phoneNumber: Company Phone Number;
  website?: Website;
}

The import statement is clearly incorrect. It seems to me that joi-to-typescript takes label to mean that we’re referencing another named exported schema, which is not our intention.

Labels are handy for customizing the error messages that Joi throws on validation failures. Is there a way that this behaviour might be made configurable, or perhaps default to ignoring label modifiers on object properties?

To be clear, we expect an output similar to this one:

export interface RegisterAccountParams {
  customerEmail: string;
  name: string;
  phoneNumber: string;
  website?: string;
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mrjono1commented, May 24, 2021

Cheers dude, I’ll get this released

1reaction
mrjono1commented, May 21, 2021

Hi @AverageHelper if you are interested in doing a Merge Request I can look at your idea further.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to use tag names containing multiple spaces | Jira Cloud
I'm facing the same issue with 'Labels' field. Error: The label 'social gallery' contains spaces which is invalid. Kindly Resolve @kerrod.williams.
Read more >
cross referencing - Are LaTeX's label names case-sensitive ...
Can the name contain spaces? I'm asking because when using Vim's snipmate TeX snippet, if I type sec and hit tab, I automatically...
Read more >
How to deal with spaces in column names? - Stack Overflow
Use the make.names() function to create safe names; this is used by R too to create identifiers (eg by using underscores for spaces...
Read more >
How to Troubleshoot and Fix Excel Pivot Table Errors
How to troubleshoot and fix Excel pivot table errors, such as PivotTable field name is not valid. Find the problem, and fix it....
Read more >
How to write SQL queries with spaces in column names
Let us understand the concept with some examples. Space in the database object name. Suppose we want to create a table named Employee...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found