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
asyncValidate doesn't allow objects for errors #506
Comments
Sounds like a bug. Can you give an example of a value returned from |
I have the problem with the following object as error:
if I just use
instead, I get the expected error. |
That's very odd. Have another look at the example, and see if you can notice anything you're doing differently. |
I had hard time figuring out what was going wrong, and got to the example many times. In the end, I only had something like this:
which was ignoring the error, while
was displaying it. I tried to follow the calls in the lib, going from asyncValidation.js _isValid2 to isValid, which seemed like an odd function to apply to an error output (as opposed to a field or field value). I didn't figure out whaat was going on in there with the recursive calls and stopped my investigation there. |
What is this {
username: 'mlarcher'
} So your error needs the same shape: {
username: 'invalid for some reason'
} If you give an error like: {
username: {
name: 'some error'
}
} ...redux-form is going to assume that your data looks like: {
username: {
name: 'mlarcher'
}
} Perhaps redux-form should be smarter, and look at your Does all that make sense? |
I understand. I implemented the synchronous validation first and didn't face this problem, so I was a bit surprised when it arose during async validation implementation.
What approach would you recommend to end up with an object as the error content ? |
Ah. This is a bug, then. Async and submit errors are saved in the state, but sync errors are not, so there must be some inconsistency there. Investigating... 🔍 |
Fix published in Thanks for this. |
Great! Thanks for the quick fix :) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
With the
validate
function we can return Objects with error name and parameters, which come in very handy for error reporting. However, if we do the same from anasyncValidate
function, the object gets lost in the way and the error doesn't appear at all on the field object.Is this a bug or is it intentional ?
The text was updated successfully, but these errors were encountered: