simple-yaml-validator
v0.0.8 validator validate yaml
simple-yaml-validator
Validate YAML strings against a simple YAML schema.
install
The normal npm way:
npm install simple-yaml-validator
use
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 = require('simple-yaml-validator')
var validate = Validator(schemaString)
var isValid = validate(resourceString)
data types
Supported data types are:
- string
- number
- binary
- timestamp
YAML schema
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: string
house_number: number
...
For deeper objects, you just write the required fields of the object:
---
address:
street: string
apartment: number
...
For arrays, write the object that's required in the array:
---
people:
- first_name: string
last_name: string
age: number
...
license
npm i simple-yaml-validator
Metadata
- VOL
- Whatever
- saibotsivad
- released 6/30/2017