Socket
Book a DemoInstallSign in
Socket

yamaxanadu

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yamaxanadu

Smol node.js tool for schema validation

latest
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

Yamaxanadu

Smol node.js tool for schema validation

Example

const Schema = require('yamaxanadu').Schema;
const Types = require('yamaxanadu').Types;

const MySchema = Schema({
	_number: Types.Number,
    _string: Types.String,
    _date: Types.Date,
    _array: Types.Array,
    _object: Types.Object,
    _null: Types.Null,
    _notNull: Types.NotNull,
    _any: Types.Any,

    _number_or_string_or_null: [Types.Number, Types.String, Types.Null]
});

const myObj = MySchema();
myObj.nooo = 1; //throws
myObj._number = null; //throws
myObj._string = 1; //throws
myObj._number = 1;
myObj._array = []
myObj._any = 'asdasdasd';
myObj._number_or_string_or_null = null;

myObj.__valid // Returns true if all scheme props are defined
const A = Schema({});
const B = Schema({hey: A});
const a = A();
const b = B({hey: a});

FAQs

Package last updated on 26 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts