immutable-schema
v0.5.2
Published
Schema validator for immutable js structures
Downloads
15
Readme
immutable-js-schema
Schema validator for immutable-js structures
Getting Started
npm install immutable-schema
Then,
import {
ListSchema, FixedListSchema, MapSchema, Exactly, OneOf
} from 'immutable-schema';
Examples
const schema = FixedListSchema(isString, isNumber, Exactly('greetings'));
const list = List.of('hi', 14.5, 'greetings');
assert.ok(schema(list));
const schema = MapSchema(
isString, isNumber,
v => isNumber(v) && (v % 2 === 0), isString
);
assert.ok(schema(
Map().set('hi', 5).set(14, 'roar')
));