1.1.0 • Published 3 years ago

@cloudseam/machine-validator v1.1.0

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
3 years ago

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.