richardscarrott / ok-computer

λ "Functions all the way down" data validation for JavaScript and TypeScript.
MIT License
79 stars 0 forks source link

API Reference #32

Open unsaved opened 11 months ago

unsaved commented 11 months ago

README file last updated 13 months ago says API "Coming soon". 13 months is not soon. Is this project dead? The idea of a super-lightweight Zod is awesome, but not if I am going to be get completely stuck at some point because something won't work and there isn't a person in the world who can assist.

richardscarrott commented 11 months ago

Unfortunately I'm no longer using OK Computer regularly, largely because Zod gained so much popularity making it a hard sell.

Although I like a lot of OK Computer's design, the main oversight from me was the lack of parsing support which Zod does well.

// zod
const data: any = { name: 'Zod         ', foo: 'true' };
const parsedData = dataSchema.parse(data);
// { name: 'Zod', foo: true }: { name: string, foo: boolean }

The downside of Zod is, if you don't need to parse, you still have to assign and duplicate the object whereas in OK Computer you can just assert an already-in-scope variable.

// ok-computer
const data: any = { name: 'Ok Computer', foo: true }
assert(data, dataValidator);
// data: { name: string, foo: boolean }

Generally though I find parsing to be necessary.

This, combined with minimal popularity, means I haven't invested the time to fully document the API.

The README does give an overview of how OK Computer works and should be used. Additionally it's got quite high test coverage so the unit tests aren't a bad place to learn the API https://github.com/richardscarrott/ok-computer/blob/master/src/ok-computer.test.ts but I appreciate this isn't ideal.

If bugs with the existing API are reported, it's likely I'll fix them. However I doubt I'll be iterating much on the design unless I find a compelling reason to do so.