Comments (2)
I see that this is intentional
Even if it succeeds, Ajv will not backtrack, so you'll get the type of the final coercion even if that's not the one that allowed the data to pass validation. If possible, structure your schema with anyOf, which won't validate subsequent subschemas as soon as it encounters one subschema that matches.
https://ajv.js.org/coercion.html
Is this something that could be added to ajv? Or no chance? Willing to give it a try if so
from ajv.
The advice I have always had around JSON Schema's oneOf
is that you probably want to use anyOf
, and that probably applies doubly so when using coerceTypes
. I doubt there is any will to change this or add another option. As you know, every option compounds the combinatorial complex and footprint of the code base, so there would have to be a very compelling reason.
from ajv.
Related Issues (20)
- Change Linter HOT 2
- Why regex pattern not works ? HOT 1
- Runtime discriminator to be able to support useDefaults within anyOf/oneOf HOT 1
- Unexpected behavior with removeAdditional and minProperties HOT 2
- Default export broken for typescript moduleResolution node16 HOT 11
- Contains object property with unknown key matching a schema HOT 1
- Distinction between addVocabulary and addKeyword in the docs
- Documentation dead links HOT 1
- Toss a Warning instead of throwing an error when adding a keyword HOT 6
- Ref within def does not act consistently
- JSONSchemaType $ref doesn't work in array type. HOT 5
- oneOf returns unwanted errors HOT 1
- Description key set as boolean returns error that it must be string HOT 2
- Validate and infer JSON Schema validated data type: introducing type providers HOT 3
- JTD schema parser errors on empty properties field HOT 1
- Implement x-inOrder subschema for in order or sequential processing HOT 3
- additionalProperties shouldn't affect TypeScript types from JTDDataType HOT 10
- option compile from addKeyword doesn't change on a remove and then add again HOT 2
- OneOf validation issue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ajv.