You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What problem do you want to solve?
I would like to be able to validate custom types using the format option. I'd like to create a JavaScript API where developers can use data types as defined by the Swagger specification.
Because the API is a JavaScript API, I'd like to also accept more types than just JSON values. I want to be able to accept any type, and convert it to a representing basic value.
For example, I would like these to work:
// Convert the date to iso8606 before validation, or even simply allow Date objects.ajv.validate({type: 'string',format: 'date-time'},newDate())ajv.validate({type: 'string',format: 'date'},newDate())// Convert the blob to base64 or a binary string before validation, or even simply allow Blob objects.ajv.validate({type: 'string',format: 'byte'},newBlob())ajv.validate({type: 'string',format: 'binary'},newBlob())
I'm able to accomplish this using Python jsonschema,but not using any JavaScript library I could find.
What do you think is the correct solution to problem?
The most efficient way would be to allow alternative types (other than string) when a format is specified.
Will you be able to implement it?
I might be, I'll have to dive into the library code.
The text was updated successfully, but these errors were encountered:
You already can define custom formats for "number" type in version 5.0.2-beta, also see migration guide. Not sure what you mean by "custom types", but for all other custom validation scenarios, including asynchronous, you can use custom keywords. See docs and also ajv-keywords package.
What version of Ajv you are you using?
4.11.3
What problem do you want to solve?
I would like to be able to validate custom types using the
format
option. I'd like to create a JavaScript API where developers can use data types as defined by the Swagger specification.Because the API is a JavaScript API, I'd like to also accept more types than just JSON values. I want to be able to accept any type, and convert it to a representing basic value.
For example, I would like these to work:
I'm able to accomplish this using Python jsonschema,but not using any JavaScript library I could find.
What do you think is the correct solution to problem?
The most efficient way would be to allow alternative types (other than string) when a format is specified.
Will you be able to implement it?
I might be, I'll have to dive into the library code.
The text was updated successfully, but these errors were encountered: