Closed
Description
For example, I want to implement lessThan
(<
) and lessThanEqual
(<=
) for string length.
There is no lessThanEqual function for string in zod, I think that it is necessary to use the min
and max
functions to implement this.
However, graphql-codegen-typescript-validation-schema can not support operation like $1 - 1
.
Reproduce Example
config: {
schema: "zod",
strictScalars: true,
scalars: {
ID: "string"
},
directives: {
constraint: {
min: ["min", "$1 - 1"],
max: ["max", "$1 + 1"]
}
},
},
input ExampleInput {
email: String!
message: String! @constraint(min: 1, max: 1000)
}
export function ExampleInputSchema(): z.ZodObject<Properties<ExampleInput>> {
return z.object({
email: z.string(),
message: z.string().min("1 - 1").max("1000 + 1")
})
}
Expected Output:
export function ExampleInputSchema(): z.ZodObject<Properties<ExampleInput>> {
return z.object({
email: z.string(),
- message: z.string().min("1 - 1").max("1000 + 1")
+ message: z.string().min(1 - 1).max(1000 + 1)
})
}
Unexpected quote is inserted.
Context
In the comment, it seems that ["min", "$1 - 1"]
is supported, so I don't know if this is a bug or a function that does not support.
If this syntax is not supported, we can just close this issue.
Metadata
Metadata
Assignees
Labels
No labels