informed icon indicating copy to clipboard operation
informed copied to clipboard

Is it possible to set multiple field errors at once?

Open syedabuthahirm opened this issue 5 years ago • 3 comments

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.?

syedabuthahirm avatar Apr 03 '19 18:04 syedabuthahirm

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.

joepuzzo avatar Apr 04 '19 02:04 joepuzzo

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.

syedabuthahirm avatar Apr 04 '19 03:04 syedabuthahirm

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.

syedabuthahirm avatar Apr 04 '19 03:04 syedabuthahirm