@indec/form-builder
Version:
Form builder
25 lines (24 loc) • 695 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _formik = require("formik");
var castErrorsFromYup = function castErrorsFromYup(yupErrors) {
var warnings = {};
if (!yupErrors) {
return warnings;
}
if (yupErrors.inner) {
if (yupErrors.inner.length === 0) {
return (0, _formik.setIn)(warnings, yupErrors.path, yupErrors.message);
}
yupErrors.inner.forEach(function (error) {
if (!(0, _formik.getIn)(warnings, error.path)) {
warnings = (0, _formik.setIn)(warnings, error.path, error.message);
}
});
}
return warnings;
};
var _default = exports["default"] = castErrorsFromYup;