Skip to content

Commit

Permalink
chore(docs): cover input transformation
Browse files Browse the repository at this point in the history
closes #75
  • Loading branch information
jasonkuhrt committed Aug 30, 2022
1 parent d1aa591 commit 09d6ce9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ This is just a taster. Places you can go next:
- [Definition (`.record`)](#definition-record)
- [Construction (`.create`)](#construction-create)
- [Input Defaults](#input-defaults)
- [Input Transformation](#input-transformation)
- [Input Validation](#input-validation)
- [Metadata](#metadata)
- [Chaining API](#chaining-api)
Expand Down Expand Up @@ -432,6 +433,20 @@ const circle = Circle.create()
// { _tag: 'circle', radius: 0 }
```

### Input Transformation

You can use zod to perform input transformations:

```ts
const Url = Alge.record('Url', {
// ...
path: z
.string()
.optional()
.transform((path) => (path === undefined ? '/' : path.trim() === '' ? '/' : path.trim())),
})
```

### Input Validation

Input is validated via Zod. For example a negative number where only positives are accepted.
Expand Down

0 comments on commit 09d6ce9

Please sign in to comment.