Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
robturtle committed Dec 10, 2019
1 parent c93f15e commit 5ad4aed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.9.0

- supports `enumSchema`
- supports registering with `CasterBuilder`
- renames `Builder` to `ClassBuilder`

## 1.8.0

- supports union types
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,22 @@ export const casters = {
};
```

### Enum types

You can easily register an enum using `enumSchema`

```typescript
import { enumSchema } from 'io-interface';

enum Status {
Pending = 'pending',
Complete = 'complete',
}

decoder.register(enumSchema('Status', Status));
const status = decoder.decode<Status>('Status', 'pending');
```

### Attach custom values

Sometimes you want attach some custom values onto the object. You can do it via the magical attribute `attrs`. If a field of the interface is named `attrs`, it will bypass the validation and be assigned as an empty object. So you should declare all fields inside `attrs` as **optional** since they're empty from the data source in the first place.
Expand Down

0 comments on commit 5ad4aed

Please sign in to comment.