You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature request] support object in directive field to method params #360
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
yeah the idea is to be able to define the error message for those in my example which I can already do in yup but can't in zod because they use object parameter and the only thing we can use as param from my understanding are string and regexp
z.string().string({required_error: 'The field is required.'})
Additionally we can't reuse the same method in zod oposite to yup.
this is valid in yup: yup.number().defined().defined().defined().defined() but invalid in zod.
Fixed in #1423. Directive configuration now supports object arguments and recursively substitutes directive argument values into the configured schema template.
Activity
Code-Hex commentedon May 5, 2023
@erwan-joly
Then generated:
This directive works even if it is not defined as a GraphQL schema.
Or does the request want to assign default error messages? (to
definedandnullable, etc)erwan-joly commentedon May 5, 2023
yeah the idea is to be able to define the error message for those in my example which I can already do in yup but can't in zod because they use object parameter and the only thing we can use as param from my understanding are string and regexp
z.string().string({required_error: 'The field is required.'})
Additionally we can't reuse the same method in zod oposite to yup.
this is valid in yup: yup.number().defined().defined().defined().defined() but invalid in zod.
Code-Hex commentedon May 13, 2023
Ah, I think I understand.
Would it be feasible to set up something like this for example?
GraphQL Schema looks like this.
The expected generation is
However, this method is not very intuitive for first-time users.
erwan-joly commentedon May 13, 2023
Yes something like this would works I think
Code-Hex commentedon Apr 25, 2026
Fixed in #1423. Directive configuration now supports object arguments and recursively substitutes directive argument values into the configured schema template.