-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Print warning instead of error when using async #2827
Comments
Agreed on this enhancement! I want it in an app I'm working on where there's a URL input field. I'd like to be able to warn users that we couldn't resolve the URL they input. I'm gonna work on this if no one else is. |
It would be great if this could have the same api as asyncValidate.
|
Hey @erikras and @griffinmichl, do you have any idea for a workaround to support warnings in asyncValidations? We really need it in our current project and we are struggling finding a solution. Thanks a lot. Regards, |
Has this have any progress? Is there a way to "push" any warnings otherway, like we have ability to change form values with this.props.change("foo","bar") ? Like this.props.warning("foo","Double check Your Foo!") ? |
Has anyone found a workaround for this? As @terolepisto says, if there's a way to manually add warnings to a form then external code could handle the async validation warning check and add to warning to the form when it returns. |
I've now used reducers to pass errors to the components which means I have
to pass them as props deep deep deep to the actual input fields and forms.
…---
Tero Lepistö
pe 26. tammikuuta 2018 klo 13.35 Andy Jump <notifications@github.com>
kirjoitti:
Has anyone found a workaround for this?
As @terolepisto <https://github.com/terolepisto> says, if there's a way
to manually add warnings to a form then external code could handle the
async validation warning check and add to warning to the form when it
returns.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2827 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AbxAqKP-chGTivqd0j3tHdcORW03oI07ks5tObh7gaJpZM4NBoVG>
.
|
Thank you! I hadn't thought of side-stepping redux-forms entirely, but that makes a lot of sense. That gives me a workaround to keep me going. I've posted this as a question to Stack Overflow, and it'd be of value to have your suggestion on there as an answer: https://stackoverflow.com/questions/48461100/how-can-i-show-a-redux-form-warning-as-a-result-of-async-validation If SO isn't your thing then no worries, I'll add it as an answer in a few days with a link attributing it to here. |
Is there any example code for this? Am I right in assuming you've a reducer updating the redux-form app state? Or some state elsewhere in the redux store passed as props? Update: I've posted an answer on the above SO question about how I implemented async warnings on field blur. |
The async validation callback passes in import { addWarning } from '../actions/warning';
import { db } from '../db';
export const asyncValidate = async (values, dispatch) => {
const someNonUniqueValueAlreadyExists = await db.findOne('someProperty', values.someValue);
if (someNonUniqueValueAlreadyExists) {
// just dispatch the action to add a warning to global state
// don't throw any error here
dispatch(addWarning('Is the user sure they want someValue here for someProperty?'));
}
}; |
@griffinmichl what was exactly agreed? I've bumped into this issue and could not find a proper solution and thinking about implementing it. There were two options discussed
I don't see what would be the preferred way. I lean towards the new API because warnings and validations are already separated on the sync API. |
@szaboat I think that new APIs would be preferable with the reason you express, the validations are separated for the synchronous validation 👍 |
Hi Folks,
i would be nice, if there will be a possibility to create warnings instead of errors when using the async validation.
And if i am not wrong only asyncErrors exists and no asyncWarnings.
We want to build async uniqueness checks and show a warning not an error, if the endpoint sad - Nope.
Is there a chance or a plan to get a feature like this?
Greetings and thank you
Jan
The text was updated successfully, but these errors were encountered: