nons
simple, lightweight schema validation library
Installation
npm i nons
Usage
const validate = require("nons");
const types = require("nons/types");
const scheme = {
this: {
can: {
as: {
nested: {
as: types.string,
},
you: types.array,
},
like: types.number,
},
with: {
"optional?": types.string,
},
},
};
validate(schema, {
this: {
can: {
as: {
nested: {
as: "works!",
},
you: ["also", "works!"],
},
like: 1,
},
with: {}, // only child is optional, but parent is required
},
});