git.schokokeks.org
Repositories
Help
Report an Issue
fs-words.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
6e9c872
Branches
Tags
develop-client_server
master
typescript
fs-words.git
server
lib
node_modules
ajv
.tonic_example.js
[add] server:lib:node_modules
Christian Fraß
commited
6e9c872
at 2021-03-08 23:52:07
.tonic_example.js
Blame
History
Raw
var Ajv = require('ajv'); var ajv = new Ajv({allErrors: true}); var schema = { "properties": { "foo": { "type": "string" }, "bar": { "type": "number", "maximum": 3 } } }; var validate = ajv.compile(schema); test({"foo": "abc", "bar": 2}); test({"foo": 2, "bar": 4}); function test(data) { var valid = validate(data); if (valid) console.log('Valid!'); else console.log('Invalid: ' + ajv.errorsText(validate.errors)); }