More than just an object validator.
These rules come out of the box and can be overwritten any time if you want.
Rule | Example | OptionType | Description | Errors |
---|---|---|---|---|
must | {must: true} |
boolean: true | Checks if this exist or if undefined | :param is required. |
typeOf | {typeOf: 'array'} |
string | works exactly like javascript typeof but uses Array.isArray if option is “array” |
:param is not typeOf :option |
min | {min: 5} |
number/string | value >= 5 | :param is too small. (Min. :option) |
max | {max: 10} |
number/string | value <= 10 | :param is too big. (Max. :option) |
minLength | {min: 5} |
string/array | value.length >= 5 | :param is too short. (Min. :option characters) |
maxLength | {max: 10} |
string/array | value.length <= 10 | :param is too long. (Max. :option characters) |
selectMin | {selectMin: 5} |
array | value.length >= 5 | Select at-least :option :param. |
selectMax | {selectMax: 10} |
array | value.length >= 10 | Select at-most :option :param. |