Comments (10)
Promises API wasn't the main reason although I quite like to have it this way. Main reason was that I made some quick tests about the other implementations and realized that no-one had something like strict
mode (https://github.com/zaggino/z-schema#strict-validation) or schema compilation. Plus some implementations I tested weren't covering all of the JSON v4 specification.
At first I thought of making a pull request for an existing implementation but then I found myself with quite a lot of free time so I've decided to read JSON schema specification word by word and implement it the way I like it to be.
It might not be the fastest implementation out there, but it's fast enough in cases where I use it (certainly not a bottleneck thing). It's also covering a huge amount of tests (https://github.com/json-schema/JSON-Schema-Test-Suite) and I'll definitely try to fix all the bugs the people can find.
from z-schema.
Thank you, for that detailed explanation! It helps me a lot.
If z-schema supports schema compilation but is not the fastest, what's the reason of schema compilation, and why are other libraries without schema compilation faster than z-schema?
from z-schema.
I haven't said its not the fastest, I never did any tests for speed and it would be quite hard to effectively compare async implementation vs sync one. This implementation is focused on features rather than speed.
Goal of schema compilation is mainly to download remote schemas that are references by your schema. See this test for example https://github.com/json-schema/JSON-Schema-Test-Suite/blob/develop/tests/draft4/refRemote.json
It would not be possible to download remote references in sync implementation. Compilation is there so you don't download it over and over again when validating tons of objects against the same schema.
from z-schema.
Let's leave it open if others had the same questions as you did ;-)
from z-schema.
I put together some performance benchmarks, results are currently like this:
$ node benchmark.js
tv4#basic x 29,134 ops/sec ±0.24% (99 runs sampled)
jayschema#basic x 935 ops/sec ±1.02% (96 runs sampled)
z-schema#basic x 13,854 ops/sec ±1.85% (90 runs sampled)
Fastest is tv4#basic
tv4#advanced x 3,668 ops/sec ±1.37% (97 runs sampled)
jayschema#advanced x 158 ops/sec ±2.28% (82 runs sampled)
z-schema#advanced x 4,046 ops/sec ±0.45% (100 runs sampled)
Fastest is z-schema#advanced
from z-schema.
@zaggino Also, it seems that your module is one of the few that populates defaults in the resulting objecting. However, I don't see a test for that — is that the case?
from z-schema.
Does it? I don't think so. But support for this (and any other fully customizable behaviour) is planned soon in #24
from z-schema.
Performance benchmarks are available here:
https://rawgithub.com/zaggino/z-schema/master/benchmark/results.html
from z-schema.
thanks @zaggino great library.
from z-schema.
FYI
version 3.x will be a complete rewrite of everything done here (all tests and features will be of course migrated), so far it's looking good: https://rawgit.com/zaggino/z-schema-3/master/benchmark/results.html
from z-schema.
Related Issues (20)
- add keyword in error objects of getLastErrors()
- Allow to specify errors to be reported
- why when schema type is string, there is no error when the value type is integer or number ? HOT 2
- Update to core-js 3.x
- Doesn't validate minimum and maximum on numbers HOT 1
- Versions mismatch cause npm error HOT 4
- Remove core-js HOT 2
- Missing type for Validator.validate(json, schema, options) HOT 3
- 'email' format accepts email addresses with several types of whitespace. HOT 3
- 'ARRAY_ADDITIONAL_ITEMS' error unreachable?
- Is there any approach to suppress an error code HOT 2
- Local schemas not being retrieved from cache
- zSchema doesn't support json-schema post 2020-12
- Vulnerabilities introduced by package validator HOT 2
- Vulnerability in Validator JS HOT 1
- Update Validator to 13.7.0 HOT 1
- `lastReport` absent in `index.d.ts` HOT 2
- Update commander as it's version marked as EOL
- Support for Unicode Properties
- List on json-schema.org 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 z-schema.