Simple model validator.
Install
npm i object-model-validator
Usage
'use strict'const types ObjectModel =const model = awaitname: typesstring{return ` is Ok`}// {name: 'Validate Object is Ok'}
Custom Property
let model = await name: typesstring lastName: typesstring fullName: optional: true type: typesstring { return ` ` } console// { name: 'Models', lastName: 'Object', fullName: 'Models Object' }
Types availables
- Integer
types.integer
- Boolean
types.boolean
- Object
types.object
- String
types.string
- Date
types.date
- Moment
types.moment
Declaration key options
type
The type of value that the key must containin
Array of available valuesparse
Function with data parameter equal to this and need return correct type valueoptional
If is required or not default falseformat
Only available in types.moment
License
MIT