Skip to content

Field meta.required setted to false when use zod transform #5042

Open
@ludhriq

Description

@ludhriq

What happened?

When i use transform on my zod schema, the property meta.required of any field is setted to false. The validation of the fields works normally, but i want to use this property to insert a hint on the label of the field to the user knows that's a required field.

I took the code in the documentation Form-Level Validation Composition API as a basis for the example, just adding the transform to the schema

const validationSchema = toTypedSchema(zod.object({
    email: zod.string()
      .min(1, { message: 'This is required' })
      .email({ message: 'Must be a valid email' }),
    password: zod.string()
      .min(1, { message: 'This is required' })
      .min(8, { message: 'Too short' }),
  }).transform((values) => {
      return values;
  })
);

Image

Note: This behavior works correctly using validation with yup, meta.required is true when using transform and the field is required

Reproduction steps

  1. Execute the code to see the meta.required setted as false
  2. Delete the transform method on the schema and meta.required will be true

Version

Vue.js 3.x and vee-validate 4.x

What browsers are you seeing the problem on?

  • Firefox
  • Chrome
  • Safari
  • Microsoft Edge

Relevant log output

Demo link

https://stackblitz.com/edit/vitejs-vite-tdty9ujv

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions