Skip to content

Commit 69e76ed

Browse files
committed
[docs] Update readme and todo files
1 parent 187c3d5 commit 69e76ed

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

readme.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Example:
124124
Standard checks provided by Facebook's PropTypes:
125125
126126
```javascript
127-
import {Type} from 'typed-props'
127+
import {Type, TypeStore} from 'typed-props'
128128

129129
// Object properties should pass all checks.
130130
const shape = Type.shape({
@@ -185,6 +185,31 @@ empty.
185185
186186
> ⚠️ .object will fail for arrays and vice versa.
187187
188+
## Named and circular types
189+
190+
Using named types it's possible to created nested structures with cross references.
191+
It could be useful for validating complex data types. Also names help to produce more
192+
meaningful error reports.
193+
194+
```javascript
195+
const store = new TypeStore()
196+
197+
const userType = Type.shape({
198+
id: Type.number.isRequired,
199+
name: Type.string.isRequired,
200+
posts: Type.arrayOf(store.ref('Post')),
201+
})
202+
203+
const postType = Type.shape({
204+
id: Type.number.isRequired,
205+
title: Type.string.isRequired,
206+
authors: Type.arrayOf(store.ref('User')),
207+
})
208+
209+
store.add('User', userType)
210+
store.add('Post', postType)
211+
```
212+
188213
## Non-standard checks
189214

190215
```javascript

todo.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
- [ ] Report stringification with intl.
66
- [ ] TypedProp serialization/deserialization.
77
- [ ] Modern export interface.
8-
- [ ] Type names.
8+
- [x] Type names.
9+
10+
### v1.4
911

10-
### v1.2
11-
1212
- [ ] Select should accept plain object as shapes.
1313
- [ ] Add context to prevent circular structures failures.
1414
- [ ] Inspect details.reason wider implementation:

0 commit comments

Comments
 (0)