@altiore/form
Advanced tools
Comparing version 3.3.7 to 3.3.8
@@ -1,1 +0,1 @@ | ||
export declare const toFlatErrors: (errors: Record<string, any>, setErrors: (fieldName: string, errors: string[]) => void) => void; | ||
export declare const toFlatErrors: (errors: Record<string, any>, setErrors: (fieldName: string, errors: string[]) => void, prefix?: string) => void; |
@@ -1,16 +0,14 @@ | ||
export var toFlatErrors = function (errors, setErrors) { | ||
Object.keys(errors).forEach(function (namePart) { | ||
var v = errors[namePart]; | ||
if (Array.isArray(v) && typeof v[0] === 'string') { | ||
setErrors(namePart, v); | ||
export var toFlatErrors = function (errors, setErrors, prefix) { | ||
if (prefix === void 0) { prefix = ''; } | ||
Object.entries(errors).forEach(function (_a) { | ||
var namePart = _a[0], errorField = _a[1]; | ||
var name = (prefix ? prefix + "." : '') + namePart; | ||
if ((Array.isArray(errorField) && typeof errorField[0] === 'string') || | ||
typeof errorField === 'string') { | ||
setErrors(name, typeof errorField === 'string' ? [errorField] : errorField); | ||
} | ||
else { | ||
var newObj = Object.entries(v).reduce(function (r, _a) { | ||
var name = _a[0], value = _a[1]; | ||
r[namePart + "." + name] = value; | ||
return r; | ||
}, {}); | ||
toFlatErrors(newObj, setErrors); | ||
toFlatErrors(errorField, setErrors, name); | ||
} | ||
}); | ||
}; |
{ | ||
"name": "@altiore/form", | ||
"version": "3.3.7", | ||
"version": "3.3.8", | ||
"description": "Form helper for building powerful forms", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102272
1609