Passing translated strings to redux-form field level validation
See original GitHub issueI am not able to come up with a way to translate field level validations in redux-form. In the example below, how can I translate a string outside of the component scope?
const minValue0 = minValue(0)('translatedString')
const TheForm => props => {
.. return(<Field
id="quantity"
type="number"
name="quantity"
validate={[minValue0]}
component={InputField} />)
}
Defining minValue0 inside the component does not work because the validation will break.
Issue Analytics
- State:
- Created 6 years ago
- Comments:17 (8 by maintainers)
Top Results From Across the Web
Redux-form Field-Level Validation & error translation with ...
I think that the value of validate props should not change between renders as it causes the field to be re-registered. What is...
Read more >Field - Redux Form
Allows you to provide a field-level validation rule. The function is given the fields current value, all other form values, the props passed...
Read more >Field - Redux Form
Allows you to to provide a field-level validation rule. The function will be given the current value of the field, all the other...
Read more >Field - Redux Form
Props you can pass to Field. name : String [required]. A string path, in dot-and-bracket notation, corresponding to a value in the form...
Read more >Field-Level Validation Example - Redux Form
The parameters to the validation function are: value - The current value of the field; allValues - The values of the entire form;...
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 Free
Top 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

You can require i18n and use it’s
tfunction outside of components (no translate hoc), sample:I wanted to document a related problem that I have managed to solve. The issue is already closed, but I believe this is the best place for others to find this hint. In my project, I am using redux, React, redux-form FieldArrays, react-select, react-i18next.
I wanted to create a form which was able to create an array as one of the form fields. I did not manage to use a function from the props for the ‘component’ of the FieldArray inside the render function of the form component, but had to create one outside of the render function. That helped me to avoid an infinite loop and is working fine.
Of course it was necessary to import i18n’s
tfunction as @jamuhl recommends https://github.com/i18next/react-i18next/issues/306#issuecomment-332868722 .