effect/schema walkthrough
✓ Published0🌍 Public
HHerbCaudill
Last edited Jun 10, 2024
Created on Jun 10, 2024
This example demonstrates how to declare and use a schema with the Effect Schema library, showing the conversion between encoded and decoded data shapes. The code defines a `Person` struct with a string `name` and an `age` field that arrives as a string but is decoded into a number. It uses `S.Struct`, `S.String`, and `S.NumberFromString` from `@effect/schema`, along with the `decodeSync` method to transform an encoded object into its typed counterpart. The test, written with Vitest, verifies the decoded result matches the expected `Person` type.
AI-generated description