Open arslanalidev opened 3 years ago
According to #473 discussion, Formik does not use Yup to do any value transformation, it uses Yup for validation only. You have to cast the value to lowercase yourself.
@markni, ok, but then why is it mentioned in the docs that it's transforming it, not just validating?
Transforms the string value to lowercase. If strict() is set it will only validate that the value is lowercase.
@markni, ok, but then why is it mentioned in the docs that it's transforming it, not just validating?
Yup only transforms values once .cast()
is called, and Formik never does. It's a bit confusing/misleading, I've just recently been tripped up by this too. You need to add .strict()
to your schema to get .lowercase()
to be validated.
Perhaps Formik should call .strict()
automatically so that options like .lowercase()
aren't complete noops otherwise
Bug report
Current Behavior
I had added the
Yup.string().lowercase()
to convert the input value into the lowercase by default.Expected behavior
It should convert the input value in the lowercase and show it in the input field.
Reproducible example
https://codesandbox.io/s/formik-codesandbox-template-forked-59h2w?file=/index.js
Your environment