fix recalc validation wrong errors

This commit is contained in:
vchikalkin 2023-04-11 12:32:41 +03:00
parent dcfa596a74
commit 7a9d8f5b94

View File

@ -233,16 +233,17 @@ export function validation(context: ProcessContext) {
() =>
$calculation.$values.getValues(Object.keys(validationSchema._def.schema.shape) as Values[]),
async (values) => {
helper.removeErrors();
const validationResult = await validationSchema.safeParseAsync(values);
if (!validationResult.success) {
if (validationResult.success === false) {
validationResult.error.errors.forEach(({ path, message }) => {
(path as Elements[]).forEach((elementName) => {
const removeError = $calculation.element(elementName).setError({ key, message });
if (removeError) helper.add(removeError);
});
});
} else {
helper.removeErrors();
}
},
{