You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
zod, a runtime validation library, has an intuitive & statically typed dx that exposes possible errors at the type level
import{z}from"zod";constUser=z.object({username: z.string(),password: z.string()});constuser=User.safeParse({username: 123,password: 'secret'});constusernameFailed: boolean=!user.success&&!!user.error.format().username// ^// this is statically typed!
Current Behavior
constUser=D.fromStruct({username: D.string,password: D.string})constuser=decoder.decode({username: 123,password: 'secret'})constusernameFailed: boolean=pipe(user,E.fold((e)=>D.draw(e).includes('username'),()=>false,// ^)// |// have to look at the implementation of 'struct' to know this)// could overlap with other errors
This approach is useful for displaying error messages (e.g. on forms), suggesting possible solutions, and/or recovering automatically from malformed input
Describe alternatives you've considered
A fork, or even a separate library (io-ts-validation?)
Additional context
Your environment
Software
Version(s)
io-ts
2.2
fp-ts
TypeScript
The text was updated successfully, but these errors were encountered:
🚀 Feature request
zod, a runtime validation library, has an intuitive & statically typed dx that exposes possible errors at the type level
Current Behavior
Desired Behavior
Suggested Solution
A non empty array of a 'sum type' of errors
A bit clunky, but maximizes compile-time information
partial implementation (playground)
Who does this impact? Who is this for?
This approach is useful for displaying error messages (e.g. on forms), suggesting possible solutions, and/or recovering automatically from malformed input
Describe alternatives you've considered
A fork, or even a separate library (
io-ts-validation
?)Additional context
Your environment
The text was updated successfully, but these errors were encountered: