UNPKG

redux-form-validators

Version:

Simple validations with redux-form / react-final-form

30 lines (25 loc) 902 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _validators = _interopRequireDefault(require("./validators")); var _helpers = require("./helpers"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } var format = (0, _helpers.memoize)(function (_ref) { var wit = _ref["with"], without = _ref.without, message = _ref.message, msg = _ref.msg, ifCond = _ref["if"], unless = _ref.unless, allowBlank = _ref.allowBlank; msg = msg || message; return (0, _helpers.prepare)(ifCond, unless, allowBlank, function (value) { if (wit && !value.match(wit) || without && value.match(without)) { return _validators["default"].formatMessage((0, _helpers.prepareMsg)(msg, 'invalid')); } }); }); var _default = format; exports["default"] = _default;