1.6.0
🔥 Support for auto-transform on submit!
Formup now supports auto-transform on submit! You can use any kind of .transform
in any schema field, and if you pass transformOnSubmit
option to useFormup
it will automatically transform your form values according to your schema when you submit your form.
You can check all implementation details here.
Suppose you do have this schema:
const exampleSchema = createSchema({
uppercaseInput: yup
.string()
.required()
.transform((value) => `${(value || '').toUpperCase()}`)
.label('Uppercase string'),
});
The transform value in yup works internally, that is, it'll execute the transform
between all form validations, but your form values will always be non-transformed:
form.values = {
uppercaseInput: "foo",
};
If you pass transformOnSubmit
to useFormup
, when you submit you form this happens:
const onSubmit = (values) => {
console.log(values.uppercaseInput); // will print "FOO"!
};