validate string by regexp or function, return error message list.
validate([{
name: 'id1',
value: '123456789012345',
validators: [
{
msg: 'please input',
method: 'require'
},
{
msg: 'identity error',
method: 'identity'
}
]
},
{
name: 'id2',
value: '123456789012345',
validators: [
{
msg: 'please input',
method: 'require'
},
{
msg: 'identity error',
method: 'identity'
}
]
}], {mode: 'single'})
validate(vlEntries, options)
- vlEntries An array of validation
- options options
see above example
validation name, used by result list
string to be validated
validator list
the message to be returned when validation fail
the validate method, can be function, regexp, string
supported regexp inner, you can use these regexp names as method directly.
only return the first error object when validation fails.
{
name: 'id1',
errors: ['errMsg', 'errMsg']
}
return error object list.
[
{
name: 'id1',
errors: ['errMsg', 'errMsg']
}, {
name: 'id2',
errors: ['errMsg', 'errMsg']
}
]