Formik: How to know when a field is validating?

Created on 8 Feb 2018  路  2Comments  路  Source: formium/formik

I have configured a YUP validation schema with a test condition, which sends the value to the server, through fetch to validate that value.
You can imagine this as a typical scenario: someone enters a new username and the app checks that it does not already exist.

The difference is that it's a list of a few boxes (usually two or three) with domains which need to be validated by the server.

Each text box has the following YUP configuration:

  1. It's a string
  2. It's required
  3. (not yet implemented) it validates the value as a properly formed domain (not URL)
  4. It validates the domain (again, using fetch)

I'd like to be able to not run 4 if 2 or 3 fail, but that's a different topic.

Even though each request is fairly quick, I'd like to display a feedback next to each text box being validated.

As far as I can see, unlike for touched and errors, there isn't a validating[value_name] prop in Formik or something similar.

Maybe I'm looking at the wrong place?

Duplicate

Most helpful comment

@jaredpalmer This is not a duplicate. The isValidating prop discussed in #126 is for the whole form and you cannot tell the validation state of a single field by that. I vote for the validating[value_name].

All 2 comments

Duplicate of #126

@jaredpalmer This is not a duplicate. The isValidating prop discussed in #126 is for the whole form and you cannot tell the validation state of a single field by that. I vote for the validating[value_name].

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sibelius picture sibelius  路  3Comments

jaredpalmer picture jaredpalmer  路  3Comments

najisawas picture najisawas  路  3Comments

ancashoria picture ancashoria  路  3Comments

giulioambrogi picture giulioambrogi  路  3Comments