5
5
[ ![ npm] ( https://img.shields.io/npm/v/typed-props.svg?style=flat-square )] ( https://npmjs.com/package/typed-props )
6
6
[ ![ Travis] ( https://img.shields.io/travis/rumkin/typed-props.svg?style=flat-square )] ( https://travis-ci.org/rumkin/typed-props )
7
7
![ ] ( https://img.shields.io/badge/coverage-100%25-green.svg?style=flat-square )
8
- ![ ] ( https://img.shields.io/badge/size-12.6 %20KiB-blue.svg?style=flat-square )
8
+ ![ ] ( https://img.shields.io/badge/size-12.60 %20KiB-blue.svg?style=flat-square )
9
9
![ ] ( https://img.shields.io/badge/deps-0-blue.svg?style=flat-square )
10
10
[ ![ npm] ( https://img.shields.io/npm/dm/typed-props.svg?style=flat-square )] ( https://npmjs.com/packages/typed-props )
11
11
@@ -105,7 +105,7 @@ Example:
105
105
// Reason helps to identify kind of problem within one validator.
106
106
// Usual values are mismatch, no_matches, and redundant.
107
107
reason: ' mismatch' ,
108
- // The next values are validator dependant .
108
+ // The next values are validator dependent .
109
109
type: ' string' ,
110
110
expect: true ,
111
111
is: false ,
@@ -117,7 +117,7 @@ Example:
117
117
## Examples
118
118
119
119
* Create [UniqItems check](examples/uniq-items.js).
120
- * [Describe API](examples/api.js) with TypedProps (with circular references resolution).
120
+ * [Describe API](examples/api.js) with TypedProps (with circular types resolution).
121
121
122
122
## Standard checks
123
123
@@ -185,7 +185,7 @@ Type.shape({
185
185
// Make type optional
186
186
optionalValue: Type .optional ,
187
187
// Determine type in runtime
188
- propertyDependantType : Type .select (
188
+ propertyDependentType : Type .select (
189
189
[
190
190
({type}) => type === ' ADD_TODO' ,
191
191
Type .shape ({/* ADD_TODO action payload shape */ }),
@@ -206,7 +206,7 @@ Type.shape({
206
206
207
207
TypedProps have it's own custom checks which make it more handful.
208
208
209
- ### ` Type .optional`
209
+ ### ` Checkable .optional`
210
210
211
211
This is pseudo check. This rule allows to make some property optional. It can
212
212
switch off previously defined ` .isRequired ` check. It's better to use with ` StrictType ` .
@@ -215,9 +215,20 @@ switch off previously defined `.isRequired` check. It's better to use with `Stri
215
215
StrictType .number .optional
216
216
```
217
217
218
- ### ` Type.select ()`
218
+ ### ` Checkable.is ()`
219
219
```
220
- (...Function|TypedProps) -> TypedProps
220
+ (value:*) -> Checkable
221
+ ```
222
+
223
+ This check validates the checkable value to strict equal ` value ` argument.
224
+
225
+ ``` javascript
226
+ Type .is (' user' )
227
+ ```
228
+
229
+ ### ` Checkable.select() `
230
+ ```
231
+ (...Function|Checkable) -> Checkable
221
232
```
222
233
223
234
This checker allow to dynamically switch between types depending on input value.
@@ -232,9 +243,9 @@ Type.select(
232
243
)
233
244
```
234
245
235
- ### ` Type .custom()`
246
+ ### ` Checkable .custom()`
236
247
```
237
- (check:(it:*) -> bool) -> TypedProps
248
+ (check:(it:*) -> bool) -> Checkable
238
249
```
239
250
240
251
Custom check accepts ` check ` argument and use it to validate the value.
@@ -267,7 +278,7 @@ class Arith {
267
278
268
279
## Checks and groups
269
280
270
- Currently there are several groups of checkers: existance , type and complex checks.
281
+ Currently there are several groups of checkers: existence , type, exact, and complex checks.
271
282
272
283
* Existance:
273
284
* isRequired
@@ -279,9 +290,11 @@ Currently there are several groups of checkers: existance, type and complex chec
279
290
* func
280
291
* object
281
292
* array
282
- * any: removes type rule
283
- * Complex:
293
+ * any: removes any other type check
294
+ * Exact:
295
+ * is
284
296
* oneOf
297
+ * Complex:
285
298
* oneOfType
286
299
* arrayOf: overwirites type check with ` array `
287
300
* objectOf: overwirites type check with ` object `
@@ -290,7 +303,7 @@ Currently there are several groups of checkers: existance, type and complex chec
290
303
* select
291
304
* custom
292
305
293
- Type and existance checks are switchable and can replace each other. It's made
306
+ Type and existence checks are switchable and can replace each other. It's made
294
307
for flexibility.
295
308
296
309
``` javascript
@@ -387,7 +400,11 @@ class IsArray extends SimpleRule {
387
400
388
401
## API
389
402
390
- ### ` TypedProps#getChecks() `
403
+ ### ` Checkable() `
404
+
405
+ Checkable is a prototype of TypeProps. It contains only check logic and has no own rules.
406
+
407
+ ### ` Checkable#getChecks() `
391
408
```
392
409
() -> Checks[]
393
410
```
0 commit comments