fix recalc validation wrong errors
This commit is contained in:
parent
dcfa596a74
commit
7a9d8f5b94
@ -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();
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user