Closed 0xcadams closed 5 months ago
Hey @StefanTerdell, just wanted to bump this. We're using your library with https://github.com/propology/hopfield and wanted to see if you're open to landing this change
@0xcadams Hello! Sorry for the delay. I do kinda like the idea. Just wondering if it should receive the result even if its undefined to give the chance to create a node when the lib fails.
No worries - cool, so you mean when selectParser
fails - the interface would change to something like:
onParseDef: ((def: ZodTypeDef, refs: Refs, schema: JsonSchema7Type | undefined) => JsonSchema7Type | false | void) | undefined;
And that would be called always, and used as a backup in case the default parsers fail.
Something like that. Not sure where the false
in the return type fits in though?
Okay great - I made those changes so onParseDef
is always called and this is used as fallback in case the parser fails.
Let me know what you think. I can update docs as well, if this interface looks good to you.
@0xcadams Hey, closing this due to inactivity, but the new override option should do what you were looking for
Sounds great - I will check out that new option
This is to enable callbacks in the parsing of Zod schemas. The use-case is that I'm doing custom validation of the Zod schema (making sure there's a description, that no unsupported types are used, etc).
Let me know if you want to see the API look any different with this.