1.0.4 • Published 5 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
null
if 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
begin
which removes spaces at beginning of value,end
which removes spaces at end of value,between_single
which replaces multiple spaces and/or new lines and tabs with a single space,between_none
which removes spaces in between andboth
which trims value on both ends. - case - Updates the value according to case provided which can either be
upper
,lower
ortitle
.
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