Comments (7)
https://runkit.com/b-wils/ajv-number-discriminator
from ajv.
Thanks for that. So after reviewing things I can see that it is indeed a deliberate restriction and there was actually a PR a while back to add support for other scalar data types.
I am just in the process of preparing a release (the first in a long time) but I can look into this afterwards and follow up with @epoberezkin.
from ajv.
Hi there, could you put together a runkit exhibiting the issue? Try and keep the example as simple as possible.
from ajv.
Judging by the example here https://ajv.js.org/json-schema.html#discriminator your schema is not quite right.
Looks like you are missing propertyName
in discriminator: {propertyName: "foo"}
.
from ajv.
Ah yes, my apologies. https://runkit.com/b-wils/ajv-number-discriminator is updated with the correct discriminator declaration and now should demonstrate the issue with numbers as discriminators.
from ajv.
Hi @b-wils, I have spoken to EP and this is not a change we're open to exploring at this time. I don't have all the context but there are reasons it should be a string and my interpretation of the spec is that it should be a string too. It should be pretty trivial to work around too.
from ajv.
Thanks for looking into it, if this is isn't part of the spec then that makes sense to not extend it in ajv.
By workaround, you mean change the fields from numbers to strings? Unfortunately our data is already in use and won't be feasible to change existing users. Replacing oneOf
with if/then
is a (slightly awkward) workaround to reduce error noise, or we may just live with the noise.
from ajv.
Related Issues (20)
- 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
- Cannot find module 'ajv/dist/compile/codegen' HOT 4
- How can I make a property value depend on the value of another property? HOT 1
- Error using multipleOf with decimals HOT 1
- Using if/then/else fails validation HOT 3
- compileParser does not appear to support properties with type `field?: Record<string, unknown>` via `JTDSchemaType`. HOT 6
- How can I access `definitions` in schema-store using `$ref`? HOT 1
- DeprecationWarning: The punycode module is deprecated #96 HOT 2
- `maxLength` constraint checking seems to not code (Hindi) unicode characters properly HOT 7
- ajv 8.13.0 upgrade doesn't work with ajv-formats 3.0.1 with TypeScript HOT 4
- compileAsync does not loadSchema a schema that is $refβd by a oneOf with a discriminator HOT 3
- How to return error when the vlaue of field is '' and set the field as required HOT 2
- ajv.compileParser does not exist on type Ajv HOT 1
- ajv schema with key or id "first" already exists HOT 2
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.