UNPKG

redux-form-validators

Version:

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

15 lines (11 loc) 465 B
import Validators from './validators' import { prepareMsg, prepare, memoize } from './helpers' let format = memoize(function ({ with: wit, without, message, msg, if: ifCond, unless, allowBlank }) { msg = msg || message return prepare(ifCond, unless, allowBlank, function (value) { if ((wit && !value.match(wit)) || (without && value.match(without))) { return Validators.formatMessage(prepareMsg(msg, 'invalid')) } }) }) export default format