Comments (8)
There is no way the validator could know which "system" type the user is intending to use. My suggestion is to examine the error message, look for errors caused by 'urn:multibody#/properties/system', then write some logic that crafts a custom error message for the user.
from jsv.
@garycourt First of all, I’m a big fan of JSV and we use it for a couple of projects at @zynga. Do you think it’d be valuable if the validator kept score of how deeply it can validate a given type from a union type and then report the error that occurs the deepest in the validation tree instead of at the top-level where none of the types from the union type match? I believe this would greatly improve the friendliness of JSV and usefulness for creating error messages in scenarios where user data is validated. If you generally like the idea, we could look into building a prototype implementation. Please let me know.
from jsv.
Thank you very much! I'm always happy to hear from people using my work. :)
I have thought about providing a better error message in this scenario, but at the time couldn't think of a way to make the message intuitive or correct. The solution you provide may work in some (or most) cases, but it still makes the assumption that the likely error is nested deeply. One solution I could implement would be to to include the sub-error reports for each union type. Then the user (you) could decide which sub-error report is the correct one.
from jsv.
Seriously, JSV is the best validator I have used and it’s been really fun formalizing our JSON protocol using it 😃
You’re right, using the depth of the error is not the right metric for measuring match. How about the number of errors per type? It’d be like the Levenstein distance between the schema and the input: How many errors away am I from a valid type? Alternatively, it’d probably be good to allow the user to choose getting full schema sub-error reports as you suggest. For the latter I’m just concerned it might be information overload for the user.
For JSON schema draft 03, this functionality would be implemented here, right? https://github.com/garycourt/JSV/blob/master/lib/json-schema-draft-03.js#L157
from jsv.
BTW, do you know any good tools for generating documentation from JSON schema? The best I found so far is mattyod/matic#1 but it doesn’t support references that JSV accepts.
from jsv.
Yes, that's the section that would implement this functionality. A distance equation is an interesting idea, and would likely be the best solution for providing a more precise error message. But the problem still remains that it is still an assumption at what union type the user was trying to use. Although this behaviour could be setup behind an environment option.
I'm afraid I have never researched any JSON Schema documentation tools before.
from jsv.
@gasi did you find any good tool for generating documentation from JSON schema ? matic doesn't support schema v4 . JSV seems dead.
from jsv.
@themihai I have not, sorry. I’ve moved projects since and don’t use JSON schemas in my day-to-day work anymore.
from jsv.
Related Issues (20)
- email validation not wokring HOT 1
- Asynchronous validators HOT 1
- Sub-schemas gets undefined restrictions HOT 1
- schemas embedded using $ref not being validated. HOT 1
- i18n support for error messages emitted by JSV HOT 2
- Extraneous .project file? HOT 1
- How to validate with additional attributes that were not exist in the schema? HOT 1
- Add support json-schema-draft-04 HOT 5
- Slow in browser
- Required array items not valid HOT 2
- trouble launching in browser HOT 1
- Add a mechansim for removing schemas. HOT 3
- Support for allOf, anyOf and oneOf HOT 2
- Is this project dead ? HOT 8
- Issues loading URI objects from Rhino
- validation passes for incorrect "date-time" formatted value HOT 1
- Please .npmignore anything that's not needed for production
- Line numbers?
- Is this project dead? HOT 3
- Change dependencies array to map HOT 3
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 jsv.