any.js 442 B

1234567891011121314
  1. import rules from "../rule";
  2. import { isEmptyValue } from "../util";
  3. var any = function any(rule, value, callback, source, options) {
  4. var errors = [];
  5. var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
  6. if (validate) {
  7. if (isEmptyValue(value) && !rule.required) {
  8. return callback();
  9. }
  10. rules.required(rule, value, source, errors, options);
  11. }
  12. callback(errors);
  13. };
  14. export default any;