bigmlcom / closchema Goto Github PK
View Code? Open in Web Editor NEWThis project forked from intelie/closchema
clojure json schema
License: Other
This project forked from intelie/closchema
clojure json schema
License: Other
the error above can be triggered with the following code:
(validate {:type "any"} 1)
Unless I'm very much mistaken, this should work better than it does:
=> (validate {:type "number" :minimum 0} 5)
true
=> (validate {:type "number" :minimum 0} -5)
false
=> (validate {:type "integer" :minimum 0} -5)
true
Specifically:
=> (validate {:type "null"} "a")
false
=> (validate {:type "null"} nil)
true
=> (validate {:type "object" :properties {:id {:type "null"}}} {:id nil})
false
=> (validate {:type "object" :properties {:id {:type "null"}}} {:id 4})
false
=> (validate {:type "object" :properties {:id {:type "number"}}} {:id 4})
true
Hmmmm...
the following code fails with the error on the title:
(validate {:type "string" :minLength 3} 1)
In at least some places, messages will not validate if the map contains a sequence rather than a vector. In particular, our dataset messages in bigmlcom/wintermute seem to not validate when :fields
or :categories
is a seq
that has not been wrapped by vec
.
See line notes from bigmlcom/wintermute#50, line 79. We should revisit this issue after this bug is fixed or debunked.
Schemas can specify a field as optional and give a default for it. It'd be nice to have a function that completes an instance of the schema according to that specification, filling in the blanks.
I've seen multiple projects migrate to cheshire, they say it's faster and since clojure.data.json breaks the API on 0.2.0 then it may make sense to make the switch now.
I can provide the pull request if it's ok for you.
By using the matches
method on java strings to validate patterns, closchema effectively requires that the pattern match the entire string. However, this appears to be incorrect. Reading http://json-schema.org/latest/json-schema-validation.html - section 5.2.3.2 notes that "regular expressions are not anchored"; further section 3.3 gives as an example that the pattern "es" should match "expression". In closchema:
user=> (schema/validate {:type "string" :pattern "es"} "expression")
false
the project lacks a license
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.