informed
informed copied to clipboard
Is it possible to set multiple field errors at once?
I didn't find a way to set multiple field errors at once to form.
In FORM API i found setError and setFormError function only but i didn't see function to set all of my field errors at once like below
setForms({
'email' : 'already exists',
'password' : 'password sholudnot contain your name'
})
Am i missing something (in API Doc) or currently this function is not supported by this package.?
Yup as it stands there is no setFormErrors
function. I can maybe add this but need to look into how difficult/if it will affect anything.
Oh, Sure. I am using laravel as a backend it's returning the object like below
{
'email' : 'already exists',
'password' : 'password sholudnot contain your name'
}
as of now i have to manually map that object to setError
. For front-end validation also i am using validation.js. it's also return the errors like below
{
'email' : 'already exists',
'password' : undefined
}
whenever we hit the server they will validate entire form at once and return them as a object. but currently i mapping that object and setting them manually. but, if we have that options by default ( like setValues
) it will helps to reduce code and better development experience.
Currently, informed has Form Level Validation but setting a error to every field individually for large forms ( 10 to 15 fields) will complex, to avoid that scenario if lib have setErrors
like setValues
it will be helpful.