1.4.3 • Published 4 years ago

@iryu54/object-validity v1.4.3

Weekly downloads
-
License
MIT
Repository
-
Last release
4 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

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.1.1

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.5

6 years ago

1.0.2

6 years ago

1.0.0

6 years ago