@@ -43,30 +43,17 @@ generates:
4343 schema : zod
4444 importFrom : ../types
4545 directives :
46- required :
47- msg : required
48- # This is example using constraint directive.
49- # see: https://github.com/confuser/graphql-constraint-directive
46+ # Write directives like
47+ #
48+ # directive:
49+ # arg1: schemaApi
50+ # arg2: ["schemaApi2", "Hello $1"]
51+ #
52+ # See more examples in `./tests/directive.spec.ts`
53+ # https://github.com/Code-Hex/graphql-codegen-typescript-validation-schema/blob/main/tests/directive.spec.ts
5054 constraint :
51- minLength : min # same as ['min', '$1']
52- maxLength : max
53- startsWith : ['regex', '/^$1/']
54- endsWith : ['regex', '/$1$/']
55- contains : ['regex', '/$1/']
56- notContains : ['regex', '/^((?!$1).)*$/']
57- pattern : ['regex', '/$1/']
55+ minLength : min
56+ # Replace $1 with specified `startsWith` argument value of the constraint directive
57+ startsWith : ["regex", "/^$1/", "message"]
5858 format :
59- # For example, `@constraint(format: "uri")`. this case $1 will be "uri".
60- # Therefore the generator generates yup schema `.url()` followed by `uri: 'url'`
61- # If $1 does not match anywhere, the generator will ignore.
62- uri : url
6359 email : email
64- uuid : uuid
65- # yup does not have `ipv4` API. If you want to add this,
66- # you need to add the logic using `yup.addMethod`.
67- # see: https://github.com/jquense/yup#addmethodschematype-schema-name-string-method--schema-void
68- ipv4 : ipv4
69- min : ['min', '$1 - 1']
70- max : ['max', '$1 + 1']
71- exclusiveMin : min
72- exclusiveMax : max
0 commit comments