Skip to content
This repository has been archived by the owner on Nov 27, 2019. It is now read-only.

Quote interface field names when needed #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xkr47
Copy link

@xkr47 xkr47 commented Oct 25, 2017

I was validating http headers using joi and tried to create a type for it

const acceptLanguage = Joi.string().example('sv').regex(/^..$/)
  .description('The language code to use e.g. en, sv, fi etc');
export const MyRequestHeadersSchema = Joi.object({
  'accept-language': acceptLanguage.required()
});

but this resulted in

export interface CreateOrderRequestHeaders {
  accept-language: string;
}

.. when the expected result would be:

export interface CreateOrderRequestHeaders {
  'accept-language': string;
}

So this PR attempts to add proper quoting of field names, when needed.

@xkr47 xkr47 force-pushed the quote-field-names-1 branch from 185e768 to ecde235 Compare October 25, 2017 16:05
@leemhenson
Copy link
Contributor

Hi @xkr47

We're no longer using or maintaining this library, having switched to use https://github.com/gcanti/io-ts/ instead. If you would like to take ownership of it, I would be happy to transfer it to you. I'd recommend io-ts as much better approach though.

@xkr47
Copy link
Author

xkr47 commented Nov 8, 2017

Thanks for the response, will look at it!

@nikcorg nikcorg mentioned this pull request Nov 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants