kenspirit / joi-to-json

Capable of converting different versions' joi object to json schema
MIT License
40 stars 18 forks source link

Support of joi-phone-number #14

Closed sergeycherepanov closed 3 years ago

sergeycherepanov commented 3 years ago

Currently, the phone number rules showed without format

kenspirit commented 3 years ago

Hi @sergeycherepanov, I haven't found any definition about phone number format / type in JSON schema, can you point me to the right place?

sergeycherepanov commented 3 years ago

@kenspirit the phone type provided by 3dr party extension https://github.com/Salesflare/joi-phone-number

kenspirit commented 3 years ago

@sergeycherepanov ic. The extension allows joi to support custom field/format.

But the JSON schema does not support these properties (defaultCountry, phoneNumberFormat, strict) and 'phoneNumber' format. What is the benefit and usage to add them to the converted JSON schema?

sergeycherepanov commented 3 years ago

hi @kenspirit I just needed to indicate the field type. Because without it the API clients can't recognize the required value format. The details about the format are not so important. But the schema should indicate that a field should be a valid phone number. Like it has done for email.

In the our system, the phone number is a unique identifier for users (something like email in common online services) and the schema is exported to 3rd party clients.

kenspirit commented 3 years ago

@sergeycherepanov In the new 2.x version, taking advantage of joi.meta() can output extension properties, such as x-foo. Please take a look.