zod
zod copied to clipboard
Getting maxLength
Hi. I want to check if a property of a schema has a maxLength. If I try the following I get an error because unwrap() either does NOT exist because it's not optional OR because .maxLength does not exist on on it if it IS optional ERROR IS - Property 'maxLength' does not exist on type 'ZodOptional<ZodString>'.
const maxLen = PatientDetails.shape.familyName.isOptional() ? PatientDetails.shape.familyName.unwrap().maxLength || undefined : PatientDetails.shape.familyName.maxLength || undefined
I just want to reliable check if it has a maxLength or not no matter if it optional or not.
Anybody know how to do this ??? I am sing TypeScript if that make any difference i.e the above failure.