Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to set multiple field errors at once? #185

Open
syedabuthahirm opened this issue Apr 3, 2019 · 3 comments
Open

Is it possible to set multiple field errors at once? #185

syedabuthahirm opened this issue Apr 3, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@syedabuthahirm
Copy link

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

@joepuzzo
Copy link
Collaborator

joepuzzo commented Apr 4, 2019

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.

@syedabuthahirm
Copy link
Author

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants
@joepuzzo @syedabuthahirm and others