Closed chrishoermann closed 1 year ago
validator.js can be used when specifing useValidatorJs
in client config
@support for @zod.refine
on scalar fields dropped in favour of @zod.custom.use(...your refine logic)
I am using this feature for comparing start
and end
dates on my schema record, however it seems that the refine
function is only receiving the value of the field that is being validated not the entire object.
/// @zod.custom.use(z.date().refine(schema => (schema.start && schema.end && schema.end < schema.start), { message: 'End date cannot be before start date.'}))
schema
is a date not the parent object. I am on an older version (2.4.1) due to compatibility issues. Not sure if this has been fixed in the later versions.
It would be nice to have support for custom refinement functions like
This refinement function should also work on
non scalar
types:furthermore it would be nice to have validator js capabilities in the refinement functions of strings. (https://github.com/validatorjs/validator.js) Possible ways of implementing this supporting regex validation: