fix reset validation
This commit is contained in:
parent
0581875dc3
commit
58ea7bba2d
@ -30,15 +30,10 @@ export const useValidation = ({
|
|||||||
|
|
||||||
// inner validation && set validation status to store
|
// inner validation && set validation status to store
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!validator) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!value) {
|
if (!value) {
|
||||||
setValidation(undefined);
|
|
||||||
calculationStore.setValidation(elementName, undefined);
|
calculationStore.setValidation(elementName, undefined);
|
||||||
} else {
|
} else {
|
||||||
const validationResult = validator(value);
|
let validationResult = validator ? validator(value) : true;
|
||||||
setValidation(validationResult);
|
|
||||||
calculationStore.setValidation(elementName, validationResult);
|
calculationStore.setValidation(elementName, validationResult);
|
||||||
}
|
}
|
||||||
}, [value, validator, elementName]);
|
}, [value, validator, elementName]);
|
||||||
|
|||||||
Reference in New Issue
Block a user