Validate YAML strings against a simple YAML schema.
The normal npm way:
npm install simple-yaml-validator
What you'll need is a YAML schema file that defines what required fields are (check out one of these example schemas), and the YAML data to validate. Pass them in as strings:
var Validator =var validate =var isValid =
Supported data types are:
Every field specified in the schema is required to exist, and the property must exist. There's plenty of examples in the test folder. Basically just write the YAML file that you want, like so:
---street_name: stringhouse_number: number...
For deeper objects, you just write the required fields of the object:
---address:street: stringapartment: number...
For arrays, write the object that's required in the array:
---people:- first_name: stringlast_name: stringage: number...