Part of the Node Validation Essentials workshop series by Simon Plenderleith.
- Open this project in your browser
- Run any of the examples below
Note: Currently only works in Chrome, Edge or Brave browsers.
git clone
this repository- Run
npm install
- Run any of the examples below
Requires Node.js >= v14.13.0 (how to install).
Defined in package.json.
Run the code in example-ajv.js:
node example-ajv.js
Run the code in example-fluent-json-schema.js:
node example-fluent-json-schema.js
The iceCreamData
object in example-ajv.js fails validation
against the JSON schema we've defined (iceCreamSchema
).
Challenge: Change the schema so the stock
property allows for
a value which is either an integer
or null
.
A couple of rules:
- You can only use the Understanding JSON Schema page on the
type
keyword as a reference — it contains all the information you need for this challenge.
- You can't change the data in the
iceCreamData
object.
When you run the script and see the message:
The ice cream data is valid! 🍨
...you've completed the challenge.
Good luck!
This project is licensed under the MIT License.