@cloudseam/machine-validator

1.1.0 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @cloudseam/machine-validator

Weekly Downloads

9

Version

1.1.0

License

Apache-2.0

Unpacked Size

31.2 kB

Total Files

10

Last publish

Collaborators

  • mikesir87