Schema.decode for validation
Schema.decode validates unknown data and returns a typed result. Invalid data produces a ParseError on the error channel.
In the anti-pattern, we trust input. In the Effect way, we validate.
- Use
Schema.Struct({ ... })to define shapes - Use
Schema.decodeUnknown(schema)(data)to validate - Returns Effect - success or ParseError
Loading code editor...