I'm creating a React app and I want to use react-localize-redux for translation and yup for validation. My problem is in understanding how to combine them.
I know that I can either pass strings to yup-require or a function, as this is the signature:
mixed.required(message?: string | function): Schema
This works perfectly when I just pass a string, but I don't get it how I then can pass a translation of my react-localize-redux after importing the
import { Translate } from 'react-localize-redux';
module, where I'm used to JSX components like
<Translate id="you-can-login-now" />
which returns my translated string then. I have totally no idea..
My code:
import { Translate } from 'react-localize-redux';
import * as Yup from 'yup';
<Formik
initialValues={this.state.data}
validationSchema={Yup.object().shape({
name: Yup.string().required('required')
})}
...
/>