MattIPv4 - :WaveDoggo: Hey Zod experts. Given a...
:Wave_Doggo: Hey Zod experts. Given an arbitrary Zod schema, is there a way I can strip refinements off any string types?
3 Replies
I have this after some back and forth with Copilot, which seems to work but absolutely does not infer the types correctly:
Can you describe what you're actually trying to do? You want to keep any other effects like transforms, preprocessing, piping, native string refiners (like .email, .uuid, etc), but remove anything explicitly defined as a
refine
or superRefine
?I ended up finding a different way around the actual underlying issue I was trying to solve for here, but, to entertain what I was trying to acheive here:
I have an arbitrary schema that I have no control over that has some props that're strings but then have
refine
s on them that check they're in a known set of string constants. Ideally I'm looking for a way to stripe those refine
s off so that those props are just generic strings again.
I think the logic I had above was pretty close, but I couldn't wrap my head around the recursive types w/ infers that I'd need to strip the refinements out of the schema type generic.