Dynamically changed validation prop
See original GitHub issueAre you submitting a bug report or a feature request?
Bug?
What is the current behavior?
If you dynamically change validation prop or render Field without validation prop with name of the field that had this prop before, the validation still remains.
{
check === 'yes' ?
<Field name='lastName' type='text'
component={renderField}
validate={[required]}/> :
<div><Field name='lastName' type='text'
component={renderField} />No validation</div>
}
https://jsfiddle.net/e8osasy2/4/ In the example:
- Touch “Last” field (validation error will appear)
- Change “yes” to any other value
What is the expected behavior?
validation error should go away as soon as validation prop is changed
What’s your environment?
6.5.0
Other informations
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Validate props with PropTypes if it have dynamic name
In my react app I have component, in which i pass props. Props can have different names. I want validate them with PropTypes...
Read more >How to dynamically/conditionally change the Required ...
I have not yet discovered how to access the fields' Required property after the form is rendered, or how to inform the validation...
Read more >Dynamic field validation in Reactjs | by Unisha Acharya
In this article, we will be validating the dynamic fields. ... Dynamic field validation in Reactjs ... onChange={(e) => props.change(e)}
Read more >Form - Dynamic change required field validation
Disclaimer: The information provided on DevExpress.com and its affiliated web properties is provided "as is" without warranty of any kind.
Read more >How to Add Form Validation to React Dynamic Forms
Formik and Yup can help to create form validation in React. ... In config.json , change the existing code to: { "development": {...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I guess you shouldn’t change
validate
prop.Instead you can move validate logic into
validate
function itself:https://jsfiddle.net/e8osasy2/6/
http://redux-form.com/6.5.0/docs/api/Field.md/#-validate-value-allvalues-props-error-optional-
@alvelig Thanks for your clear communication throughout this thread. We’ve recently had a change which you can see here: #3094 and read about here: #3211. I suspect this may have fixed or changed the nature of this issue.
Would you be willing to verify on a recent version of redux-form after that change?