update handlechange to modify form validation logic
This commit is contained in:
1 parent
86c31eaaf6
commit
47f8494193
1 file changed
+11
-10
@@ -94,12 +94,17 @@ const Settings = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let inputValue = value;
|
||||||
|
if (id === "ttl") {
|
||||||
|
inputValue = value.replace(/[^0-9]/g, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
const updatedForm = { ...form, [id]: inputValue };
|
||||||
const { error } = settingsValidation.validate(
|
const { error } = settingsValidation.validate(
|
||||||
{ [id]: value },
|
updatedForm,
|
||||||
{
|
{ abortEarly: false }
|
||||||
abortEarly: false,
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!error || error.details.length === 0) {
|
if (!error || error.details.length === 0) {
|
||||||
setErrors({});
|
setErrors({});
|
||||||
} else {
|
} else {
|
||||||
@@ -110,12 +115,8 @@ const Settings = () => {
|
|||||||
setErrors(newErrors);
|
setErrors(newErrors);
|
||||||
logger.error("Validation errors:", error.details);
|
logger.error("Validation errors:", error.details);
|
||||||
}
|
}
|
||||||
let inputValue = value;
|
|
||||||
id === "ttl" && (inputValue = value.replace(/[^0-9]/g, ""));
|
setForm(updatedForm);
|
||||||
setForm((prev) => ({
|
|
||||||
...prev,
|
|
||||||
[id]: inputValue,
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO Handle saving
|
// TODO Handle saving
|
||||||
|
|||||||
Reference in new issue
Block a user