added also required validation and generic error validation on typing.
This commit is contained in:
@ -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();
|
||||
|
Reference in New Issue
Block a user