no-input
A useful tool to validate any input.
Install
Usage
- Options
;
data
{Object} required input data you want to validatenameOrOptions
{String|Object} required key may be exist indata
OR options withname
,pattern
,default
anderror
pattern
{RegExp|Array|Function|Object|String...} optional validatordefault
{Mixed} optional default value when invalid (Function will get the return value)error
{Error} optional special error to throwthrow
{Error} if the value is invalid without default value
- Custom error handler
input { return 'Invalid input ' + name;}
- Example
var data = type: 'cat';var value = ;//ORvar value =