1.0.4 • Published 7 years ago
complete-validator v1.0.4
complete-validator
Installation
$ npm install complete-validator Usage
const validator = require('complete-validator');
const results = validator(object, schema, customMessages, arrayValuesOrMomentOrDateArgument);The validator function returns an object with value and errors properties.
- value - contains a copy of the original object with its values optimised according to their types
- error - contains array of validation errors if any or
nullif non.
API
For now, refer to Laravel validation docs, validation API will be updated in the next release.
An extra feature added is clean which works strings only. Arguments can be either or both of spaces and case.
- spaces - Removes spaces in the value, its arguments can be
beginwhich removes spaces at beginning of value,endwhich removes spaces at end of value,between_singlewhich replaces multiple spaces and/or new lines and tabs with a single space,between_nonewhich removes spaces in between andbothwhich trims value on both ends. - case - Updates the value according to case provided which can either be
upper,lowerortitle.
Sub arguments are provided in dot format i.e.
'spaces.both.between_single,case.title'NB: Please bear with me, documentation coming up next
Licence
MIT