Comments (7)
I'm not able to reproduce this one. The expected result is for it to throw the result of meta-validation. When I attempt to validate that schema I get the following error.
{
keyword: 'http://json-schema.org/draft-06/schema#validate',
absoluteKeywordLocation: 'http://json-schema.org/draft-06/schema#',
instanceLocation: 'http://example.com/test#',
valid: false,
errors: [
{
keyword: 'http://json-schema.org/draft-06/schema#additionalProperties',
absoluteKeywordLocation: 'http://json-schema.org/draft-06/schema#',
instanceLocation: 'http://example.com/test#/properties',
valid: false,
errors: [Array]
},
{
keyword: 'http://json-schema.org/draft-06/schema#properties',
absoluteKeywordLocation: 'http://json-schema.org/draft-06/schema#/properties',
instanceLocation: 'http://example.com/test#',
valid: false,
errors: [Array]
}
]
}
from json-schema-core.
OK--thanks for investigating. I'll take another look at my code, and then provide an update here.
from json-schema-core.
Alright, here's what I got tripped up on. When I call validate:
const output = await JsonSchema.validate(schema, instanceJSON, JsonSchema.VERBOSE);
If the schema fails to validate, then this throws--but it doesn't throw an Error. Instead, it throws an output object for the schema. Is this the intended behavior?
from json-schema-core.
Yes, that's the expected behavior. I've never been happy with the way meta-validation errors are handled. Throwing the output was intended to be temporary until I came up with something I liked better, but I haven't come up with anything yet, so it's still there. I wanted to avoid having to make a custom error implementation, but at this point I should probably do that or prioritize coming up with an approach I like better.
from json-schema-core.
Got it. As a client, I think the throw seems reasonable, but not extending Error definitely tripped me up. I would have expected a custom error from which I could retrieve the output object.
Do you want me to close this? Or leave it open as a reminder to revisit this? :)
from json-schema-core.
Thanks for the feedback. You can leave it open. I'm not sure what I'm going to do yet, but I'll figure something out and take care of it soon.
from json-schema-core.
I added the custom Error class. I'm still not super happy with it. The part I don't like is that you have to know to look for the validation results in custom property output
. I'm concerned that people won't know to look for this field. But, it's not good enough the way it is and I didn't come up with a better option, so this will have to do.
from json-schema-core.
Related Issues (8)
- Can't access file resource from network context HOT 6
- Error: https://json-schema.org/draft/2020-12/schema is not a schema. Found a document with media type: application/octet-stream HOT 3
- Default Schema Version HOT 2
- Unhandled Promise Rejections with multiple unresolved $refs HOT 4
- โcosntโ in the README HOT 1
- Failed to fetch local file in windows HOT 2
- SHOULD accept application/json and not make application/schema+json a MUST HOT 7
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 json-schema-core.