1.4.3 • Published 3 years ago

@iryu54/object-validity v1.4.3

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Object-validity

coverage

Actions Status

Install

npm i @iryu54/object-validity

Usage

A schema object is a collection of field to validate. Each field are a function with a validator object. A validator function can be chained. ex:

validator => validator.be('number').min(2).max(5)
const {Schema} = require('@iryu54/object-validity')
const objectToValidate = {
  number: 10,
  nestedObject: {
    object: {}
  },
  arrayNested: [
    {array: []}
  ]
}
const {valid, error} = new Schema({
  number: validator=>  validator.be('number').min(9).max(12),
  nestedObject: { object: v => v.object() },
  arrayNested : [
    { array: v => v.array() }
  ]
}).validate(objectToValidate)
expect(valid).to.be.true
expect(error).to.be.null
1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.1.1

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.5

5 years ago

1.0.2

5 years ago

1.0.0

5 years ago