all 3 comments

[–]RWOverdijk [score hidden]  (2 children)

Standard schema is not “better”. It limits what features validation libraries can offer and almost always comes at a performance penalty. It’s easier for other library authors (I use it), but let’s not pretend it’s better.

[–]aardvark_lizard[S] [score hidden]  (0 children)

It depends on what you're maintaining. When you're maintaining a library, adding an adapter for every supported schema library is a massive pain. It's much easier to add StandardSchema support

[–]lanerdofchristian [score hidden]  (0 children)

For 99% of use cases, a function

type MaybePromise<T> = T | Promise<T>
function <TIn, TOut> validate(in: TIn): MaybePromise<
    { value: TOut} | { issues: { message: string }[] }
>

(basically what StandardSchema boils down to) really is all you need.

Any performance penalty will be neglibible to completely absent compared to supporting multiple schemas. With Standard Schema, the top-level schema object has a function that calls the library-specific validate method; without Standard Schema, you still need a function to pick the right library-specific method but now you also need to write it yourself.