nostr:npub1xzrkzsrnr83vn7h0udq6tnapwpswy5equlrtkn3nu0e0anlmzynqne0qap what issues did you run into with zod? I've done zero research on this but I know the AI models are have easier time writing zod and JSON schema so my thinking was to use them to produce the schemas
nostr:npub1uac67zc9er54ln0kl6e4qp2y6ta3enfcg7ywnayshvlw9r5w6ehsqq99rx proposed schemata is per issue, extensible to any language.
nostr:npub1ye5ptcxfyyxl5vjvdjar2ua3f0hynkjzpx552mu5snj3qmx5pzjscpknpr - regarding zod, nostr:npub1xzrkzsrnr83vn7h0udq6tnapwpswy5equlrtkn3nu0e0anlmzynqne0qap went through the pain of zod schema, and to my understanding is in agreement with nostr:npub1uac67zc9er54ln0kl6e4qp2y6ta3enfcg7ywnayshvlw9r5w6ehsqq99rx that the schemata approach is the most flexible/extensible for the variety of nostr applications.
https://www.npmjs.com/package/nostr-commerce-schema
nostr:npub1xzrkzsrnr83vn7h0udq6tnapwpswy5equlrtkn3nu0e0anlmzynqne0qap is also looking at extending to e.g. mkstacks.
Regarding the validation application - yes for applesauce this is a great use case for schemata.
Discussion
The big argument going round is that they don’t handle tuples effectively, Nostr tags are tuples, effectively, and I’ve experienced quite a lot of false-positives-and-negatives using Zod, requiring pretty unintuitive code-jitsu to remedy.
Are the issues with tuples in the generated typescript types or the validation of events. Looking at their docs they do have a tuple type and it seems to support rest types [string, string, ...string]
I'm curious because I like zod. although the more I look into this I'm thinking a JSON schema approach might be simpler then limiting it to TS
Great question, and definitely worth exploring / validating. Keep me in the loop, I’m all-brain-elsewhere at the moment but in a few months I’ll be asking these juicy questions.
I think cross-language availability is a big selling point for JSON schemas, as well.
Need to do more testing, but I tend to agree. JSON schemas would allow any language to use it, although I'm worried that some of the stuff like pattern matching or strict Typescript types might not get compiled. and thats mainly what I'm after.
I want to call a isContacts method in typescript and know for certain that all "p" tags have a hex value