mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-26 14:05:04 +08:00
20 lines
628 B
JavaScript
20 lines
628 B
JavaScript
|
|
import * as util from '../util';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Rule for validating whitespace.
|
||
|
|
*
|
||
|
|
* @param rule The validation rule.
|
||
|
|
* @param value The value of the field on the source object.
|
||
|
|
* @param source The source object being validated.
|
||
|
|
* @param errors An array of errors that this rule may add
|
||
|
|
* validation errors to.
|
||
|
|
* @param options The validation options.
|
||
|
|
* @param options.messages The validation messages.
|
||
|
|
*/
|
||
|
|
function whitespace(rule, value, source, errors, options) {
|
||
|
|
if (/^\s+$/.test(value) || value === '') {
|
||
|
|
errors.push(util.format(options.messages.whitespace, rule.fullField));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export default whitespace;
|