JSON Schemas defining Form Builder core components
In your components module
npm install @ministryofjustice/fb-specifications --save-dev
To lint schemas and schema test data and validate the schemas
test-specifications
Location
specifications/${name}/${name}.schema.json
Location
specifications/definition/${name}/${name}.definition.schema.json
Examples for the schemas are JSON files located in a data directory at the same level as the schema file.
Valid examples should be in
specifications/${name}/data/valid/
data.invalid/*.json
specifications/${name}/data/invalid/
NB. All of the following commands should be run from the fb-specification root directory:
Check that test data in each specification’s directory validates against the corresponding schema.
npm run test:schemas
This command will use the data in the specified schema’s examples directory
node validate.js -s {schemaName}
Validate a single file or directory
node validate.js {path}
Pass the -i flag (or --invalid)
node validate.js {path} -i
By default, all errors encountered are displayed. To show only the first error encountered, use the --n-a flag (or --no-allErrors)
node validate.js {path} --help
npm run lint
this runs
lint:schemas
lint:data
which checks that the files are valid JSON
To format the JSON files
format:schemas
format:data
General documentation is located in the documentation directory.
Schemas that have a corresponding .schema.md file will have that content included in the schema’a documentation.
Data test files that have a corresponding .md file will be included in a spec's documentation as examples
- Check out fb-documentation
- node expandAll.js
- cd fb-documentation
- npm run build
- Commit and push resulting changes