Revert "FE - Advanced Settings Page Validation and Error Handling"

This commit is contained in:
Alexander Holliday authored and GitHub committed 2024-10-22 18:21:10 +08:00
1 parent c9864d9075
commit 238db5bc8f
4 files changed
+279 -339

No files matched your search

-25
View File
@@ -1,25 +0,0 @@
const buildErrors = (prev, id, error) => {
const updatedErrors = { ...prev };
if (error) {
updatedErrors[id] = error.details[0].message?? "Validation error";
} else {
delete updatedErrors[id];
}
return updatedErrors;
};
const hasValidationErrors = (form, validation, setErrors) => {
const { error } = validation.validate(form, {
abortEarly: false,
});
if (error) {
const newErrors = {};
error.details.forEach((err) => {
newErrors[err.path[0]] = err.message?? "Validation error";
});
setErrors(newErrors);
return true;
}
return false;
};
export { buildErrors, hasValidationErrors };