Skip to content

Commit cea1e43

Browse files
committed
[docs] Removes a mess from initial example
1 parent 18ae4ef commit cea1e43

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

readme.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,37 +48,28 @@ Custom types check:
4848

4949
import {Type as T, StrictType as ST, check} from 'typed-props'
5050

51-
const userType = T.shape({
51+
const type = T.shape({
5252
id: T.number.isRequired,
5353
name: T.string.isRequired,
5454
email: T.string,
5555
}).isRequired
5656

5757
// Or
5858

59-
const userType = ST.shape({
59+
const type = ST.shape({
6060
id: ST.number,
6161
name: ST.string,
6262
email: ST.string.optional,
6363
})
6464

65-
check({
65+
const data = {
6666
id: '1',
6767
name: null
68-
}, userType); // Produce an array of issues
69-
70-
// Type behavs like Facebook's PropTypes, it requires isRequire to be set
71-
// to infiltrate undefined properties
72-
check(1, Type.number) // -> [] Valid
73-
check(undefined, Type.number) // -> [] Valid
74-
75-
check(1, StrictType.number) // -> [] Valid
76-
check(undefined, StrictType.number) // -> [Issue] Invalid
77-
78-
// There is a way to make type defined as strict optional.
79-
check(undefined, StrictType.number.optional) // -> [] Valid
68+
}
8069

81-
check({count: 1}, Type.shape({count: Type.number}))
70+
const issues = check(data, type)
71+
typeof issues // Array
72+
issues.length // 1
8273
```
8374

8475
### Output

0 commit comments

Comments
 (0)