Skip to content

cloudseam/machine-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Machine Spec Validator

This project contains the machine specifications and a validator to validate a given JSON structure against the spec.

Usage

npm install @cloudseam/machine-validator
yarn add @cloudseam/machine-validator

In your code, require the project, which is simply the validating function.

const validator = require('@cloudseam/machine-validator');
const machineConfig = {}; // Load this from a file or somewhere else

validator(machineConfig)
    .then(() => console.log("Success"))
    .catch((err) => console.error("Failure", err);)

API

validator(machineConfig)

machineConfig - object of the machine config, possibly loaded from a YAML file

return - the machine config if valid. Otherwise, throws an error describing the fault.

NOTE: The validator makes heavy use of the Joi project because is makes validating JSON structures easy. However, some of the error messages are fairly cryptic. That will be fixed up in future releases.

Development

Simply run docker-compose up -d to spin up a local dev environment.

About

Validators for machine specs

Resources

License

Stars

Watchers

Forks

Packages

No packages published