Skip to content
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

Feasibility of adding custom types #967

Closed
mycrl opened this issue Mar 7, 2019 · 1 comment
Closed

Feasibility of adding custom types #967

mycrl opened this issue Mar 7, 2019 · 1 comment

Comments

@mycrl
Copy link

mycrl commented Mar 7, 2019

Adding custom validation now only implements format validation via addFormat, whether to consider adding custom types for more convenient type definitions.

Use a custom type ObjectId.

{ _id:  { type: "ObjectId" } }

validation.

this is mongodb Objectid.

{ _id: xxx._id  }

This way to implement any type I want through a custom type.

@epoberezkin
Copy link
Member

Sorry, it has been previously been proposed and it won’t be supported. Type is a special keyword in JSON Schema and Ajv processes it differently from other keywords, so redefining it would be very complex. Also I do think it’s a bad idea to redefine standard keywords - it is better to define new custom keywords via available extension mechanism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants