Passing additional data into <Field /> which will be accessible in validate
See original GitHub issueI need to pass additional object myCustomData which I can access in meta.data <Field name="firstName" myCustomData={{isOk: true}} validate={(value, values, meta) =>{ return meta.data.myCustomData.isOk ? null : 'Error' }} />
Passing additional data into Field which I can access in 'validate ’ function would be very helpful
_Originally posted by @lock in https://github.com/final-form/react-final-form/issues/355#issuecomment-544117342_
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Restrict data input by using validation rules - Microsoft Support
Validations rules help you check data as it is added to your Access desktop database which improves accuracy and consistency of data entry....
Read more >Validating Input | Web Accessibility Initiative (WAI) - W3C
Validation should aim to be as accommodating as possible of different forms of input for particular data types. For example, telephone numbers are...
Read more >Data Validation – How to Check User Input on HTML Forms ...
We need form validation anytime we are accepting user input. We must ensure that the data entered is in the correct format, lies...
Read more >Client-side form validation - Learn web development | MDN
Go to any popular site with a registration form, and you will notice that they provide feedback when you don't enter your data...
Read more >Validation - Laravel - The PHP Framework For Web Artisans
As you can see, the validation rules are passed into the validate method. Don't worry - all available validation rules are documented. Again,...
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
Just an avid consumer of this library, so author/maintainers feel free to correct me, but my advice would be to use a curried function here. We do this all the time:
With this pattern you have/can have access to whatever values you need.
@marrkeri You didn’t write that you wanted to update the data, so I didn’t answer that question. The code I wrote above is just the initialisation part. If you want to update meta.data you can do this with a mutator. Or even install one of Erik’s companion libs for this (it’s actually just one function). https://www.npmjs.com/package/final-form-set-field-data
One of Erik’s blog posts describes this. The second part (about field warnings) might apply to your use case: https://blog.cloudboost.io/final-form-decorators-calculated-fields-and-warnings-bf9cccd21b7e