whitespace.js 773 B

123456789101112131415161718192021222324
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _util = require("../util");
  7. /**
  8. * Rule for validating whitespace.
  9. *
  10. * @param rule The validation rule.
  11. * @param value The value of the field on the source object.
  12. * @param source The source object being validated.
  13. * @param errors An array of errors that this rule may add
  14. * validation errors to.
  15. * @param options The validation options.
  16. * @param options.messages The validation messages.
  17. */
  18. var whitespace = function whitespace(rule, value, source, errors, options) {
  19. if (/^\s+$/.test(value) || value === '') {
  20. errors.push((0, _util.format)(options.messages.whitespace, rule.fullField));
  21. }
  22. };
  23. var _default = exports.default = whitespace;