UNPKG

redux-form

Version:

A higher order component decorator for forms using Redux and React

28 lines (25 loc) 766 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var defaultShouldAsyncValidate = function defaultShouldAsyncValidate(_ref) { var initialized = _ref.initialized; var trigger = _ref.trigger; var pristine = _ref.pristine; var syncValidationPasses = _ref.syncValidationPasses; if (!syncValidationPasses) { return false; } switch (trigger) { case 'blur': // blurring return true; case 'submit': // submitting, so only async validate if form is dirty or was never initialized // conversely, DON'T async validate if the form is pristine just as it was initialized return !pristine || !initialized; default: return false; } }; exports.default = defaultShouldAsyncValidate;