Skip to content

Latest commit

 

History

History
30 lines (24 loc) · 522 Bytes

README.md

File metadata and controls

30 lines (24 loc) · 522 Bytes

Schemable

JSON Object Type Check Library

Usage

const user = T.obj({
    name: T.str.atLeast(4),
    pass: T.str.match(/[0-9a-zA-Z]{4,}/),
    age: T.int.atLeast(0),
    sex: T.oneOf(["male", "female"])
})

user.validate({
    name: "Beckey",
    pass: "P4SS",
    age: 19,
    sex: "female"
})

assert.throws(() => user.validate({
    name: "Beckey",
    pass: "P",
    age: 19,
    sex: "female"
}))

For more detail, see example.js