Skip to content

[Feature request] support object in directive field to method params #360

@erwan-joly

Description

@erwan-joly

would be nice to support object in directive parsing.

Yup currently allow you to define a specific error message string quite easily for required.

directives: {
  required: {
    errorMessage: "defined"
  }
}

sadly this seems to be the equivalent in zod and it does not work. If we put the content between quotes we end up with this z.string().string("{required_error: 'The field is required.'}").
This is having two issues:

  • zod doesn't support multi chaining the same method so would need to remove the first one
  • the object is between quote :/
directives: {
  required: {
    errorMessage: ["string", { required_error: '$1' }]
  }
}

Had a quick look but sadly my understanding of the lib is quite small so haven't been able to add that feature.

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