Answer the question
In order to leave comments, you need to log in
Is it possible to "build" a yup validation schema?
The bottom line is that I receive form fields and conditions for their validation from the server.
Is it possible to assemble a validation scheme depending on the yup conditions, for example, in this way:
let s = Yup.string()
if (current.minimum && current.minimum !== '0') {
s.concat(Yup.string().min(Number(current.minimum)))
}
if (current.maximum) {
s.concat(Yup.string().max(Number(current.maximum)))
}
if (current.required === 'required') {
s.concat(Yup.string().required('!!'))
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question