Add Synchronous Validation to a redux-form using field-level Validation

InstructorRory Smith

Share this video with your friends

Send Tweet

There are two ways to handle validation in redux-form. In this example, we are going to find out how to use field-level-validation using reusable functions, which presents a clean, readable syntax attached to each redux-form Field element.

Stefan Osorio
~ 6 years ago

How would you go about including the name of the field in the error message in this version?

Rory Smithinstructor
~ 6 years ago

How would you go about including the name of the field in the error message in this version?

Hi Stefan, to achieve that I would probably use the validation function approach.

Christian
~ 6 years ago

@Stefan The validation function provides you that as a 4th argument. See https://redux-form.com/7.4.2/docs/api/field.md/#-code-validate-value-allvalues-props-name-gt-error-code-optional-

@Rory In this episode example it's not explicit how you avoid getting 'property length of undefined' on validation. Maybe you should also mention that.