how to migrate yup code fro v0.32.11 to v1.0?

21 views Asked by At

I've already asked at https://github.com/jquense/yup/pull/1542#issuecomment-1738643036 but got no real answer.

How do we have to change this?

    then: yup.object().shape({
      field_3: yup.string().required(content.errors.required),
    }),
    otherwise: yup.object().shape({
      field_1: yup.string().required(content.errors.required),
      field_2: yup.mixed().when('regulation', {
        is: regulated,
        then: yup.string().required(content.errors.required),
      }),
    }),

And this?

    then: yup
      .number()
      .min(0, dimensions.height.errors.atDefault)
      .max(25, dimensions.height.errors.atDefault)
      .required(content.errors.required),
    otherwise: yup
      .number()
      .min(0, dimensions.height.errors.main)
      .max(25, dimensions.height.errors.main)
      .required(content.errors.required),

Especially then: yup.object().shape({. Is this now then: (schema) => schema.object().shape({ or then: (schema) => schema.shape({?

And yup.number(). becomes now (schema) => schema.?

I already tried to understand the changelog entries and migration guide and asked at https://github.com/jquense/yup/pull/1542#issuecomment-1738643036 but got no answer and did not find out the solution so far.

0

There are 0 answers