UNPKG

redux-form

Version:

A higher order component decorator for forms using Redux and React

27 lines (23 loc) 715 B
var getErrorKeys = function getErrorKeys(name, type) { switch (type) { case 'Field': return [name, name + "._error"]; case 'FieldArray': return [name + "._error"]; default: throw new Error('Unknown field type'); } }; export default function createHasError(_ref) { var getIn = _ref.getIn; return function (field, syncErrors, asyncErrors, submitErrors) { if (!syncErrors && !asyncErrors && !submitErrors) { return false; } var name = getIn(field, 'name'); var type = getIn(field, 'type'); return getErrorKeys(name, type).some(function (key) { return getIn(syncErrors, key) || getIn(asyncErrors, key) || getIn(submitErrors, key); }); }; }