-
-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
duration #395
Comments
@nasht00 i believe you can solve this by using the new e.g. formats: [
{
name: 'my-three-digit-format',
type: 'number',
// validate returns true the number has 3 digits, false otherwise
validate: (v) => /^\d{3}$/.test(v.toString()),
},
{
name: 'my-three-letter-format',
type: 'string',
// validate returns true the string has 3 letters, false otherwise
validate: (v) => /^[A-Za-z]{3}$/.test(v),
},
]; Then use it in a spec e.g. my_property:
type: string
format: my-three-letter-format' Create a format with a validator for |
going to close this out. please re-open if this solution does not meet your needs |
I'm sorry I'm confused as to how it would validate an RFC3339 duration ... What's this 3-letter-format? |
3-letter-format is just an example. |
Ah I see. Then yes I know I can write my own custom validators. |
@nasht00 i see. this makes sense. i'll reopen the ticket. ideally ajv will handle this for us, however until then (havne't checked) we could embed a customer validator to handle this by default. if you are up for creating a PR, i'll gladly review. |
@cdimascio ajv supports duration validation using the ajv-formats package. |
Would it be possible to validate string format
duration
?See discussion: OAI/OpenAPI-Specification#359
Definition: https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.7.3.1
The text was updated successfully, but these errors were encountered: