added also required validation and generic error validation on typing.

This commit is contained in:
Samuel Andert
2023-08-08 09:13:56 +02:00
parent 720282dbfd
commit c98253ceb7
2 changed files with 5 additions and 4 deletions

View File

@ -31,14 +31,13 @@
// Update the isValidated property of the store whenever the errors object changes
$: {
// Send events to the state machine based on the validation status
if (!($errors.name || $errors.email || $errors.about || $errors.age || $errors.favoriteFood)) {
let isValid = fields.every((field) => !$errors[field.name]);
if (isValid) {
$me.do.state.send('VALIDATE');
} else {
$me.do.state.send('INVALIDATE');
}
}
async function handleSubmit() {
// Manually validate the form
const validationResult = await validate();