formsy-react icon indicating copy to clipboard operation
formsy-react copied to clipboard

Support for async validations

Open mchurichi opened this issue 6 years ago • 9 comments

Is there a declarative way to add custom async validations for an specific field?

I'm trying to add server side validations for an specific field that run whenever a field value changes and the suggested solution I found is allow the user to submit the whole form, validate it in the server side, return the result and use updateInputsWithError to set the errors in the input, if any. This could work well is not the best from the UX perspective.

Another solution I can think of could be use the onChange event on the Formsy wrapped component to dispatch the needed server side validation, but this sounds a bit hacky, and since formsy already has a great custom validations support would be wonderful if I can use that.

There is a PR (https://github.com/christianalfoni/formsy-react/pull/408) in the old repo that was discarded because it uses Promises, but it's like 2 years old and things have changed since then.

Any thoughts?. Thanks.

mchurichi avatar Aug 10 '18 20:08 mchurichi

There's an open issue regarding this topic in the old repo: https://github.com/christianalfoni/formsy-react/issues/261

yantakus avatar Oct 12 '18 17:10 yantakus

@mchurichi I see a long time passed since you opened this issue. Any luck with this? I like formsy-react and wouldn't like to migrate to another solution just because of this.

yantakus avatar Oct 13 '18 08:10 yantakus

@yantakus sorry for the late response, no luck with this issue, I used the second workaround mentioned in my first comment, which is a bit hacky, but it works.

mchurichi avatar Nov 22 '18 23:11 mchurichi

I can help update the code to the latest version if there's a wish to merge it.

LeoIannacone avatar Feb 27 '19 22:02 LeoIannacone

+1 feature needed.

jabidof avatar Jan 07 '20 16:01 jabidof

The code is definitely far too different now, but the project is open to new PRs. I'm unsure of the feasibility of this, but it could be as easy as some async and awaits in the right places. @jabidof I recommend adding 👍 to the top comment since that's a common way of showing support for a feature.

rkuykendall avatar Jan 07 '20 21:01 rkuykendall

Unfinished and out of date PR, but useful reference for anyone who wants to take this on: https://github.com/formsy/formsy-react/pull/340

rkuykendall avatar Feb 15 '20 22:02 rkuykendall

Not yet implemented?

NEEDED!

May be I can help.

1aerostorm avatar Apr 03 '21 08:04 1aerostorm

Yes, you probably can @1aerostorm. Please feel free to open a PR. If you have any questions I would happily answer them.

rkuykendall avatar Apr 03 '21 19:04 rkuykendall