GitLab Commit is coming up on August 3-4. Learn how to innovate together using GitLab, the DevOps platform. Register for free: gitlabcommitvirtual2021.com

API.md 246 KB
Newer Older
1
# Objects
2

3
<dl>
4
5
<dt><a href="#rtv">rtv</a> : <code>object</code></dt>
<dd><h3>RTV.js Public Interface</h3>
6

7
8
9
<p>Provides the externally-facing API. It wraps the
 <a href="#rtvref.impl">implementation</a>, adding a bit of syntactic sugar, and
 adds the <a href="#rtv.config">configuration</a> facilities.</p>
10
</dd>
11
12
<dt><a href="#rtvref">rtvref</a> : <code>object</code></dt>
<dd><h3>RTV.js Reference</h3>
13

14
15
<p>Members herein are <em>indirectly</em> accessed and/or exposed through the
 <a href="#rtv">RTV.js Public Interface</a>.</p>
16
17
18
</dd>
</dl>

19
20
21
22
23
24
25
26
27
28
29
30
<a name="rtv"></a>

# rtv : <code>object</code>
<h3>RTV.js Public Interface</h3>

Provides the externally-facing API. It wraps the
 [implementation](#rtvref.impl), adding a bit of syntactic sugar, and
 adds the [configuration](#rtv.config) facilities.

**Kind**: global namespace  

* [rtv](#rtv) : <code>object</code>
Stefan Cameron's avatar
Stefan Cameron committed
31
32
    * [.types](#rtv.types) : [<code>Enumeration</code>](#rtvref.Enumeration)
    * [.qualifiers](#rtv.qualifiers) : [<code>Enumeration</code>](#rtvref.Enumeration)
33
34
35
36
    * [.version](#rtv.version) : <code>string</code>
    * [.config](#rtv.config) : <code>object</code>
        * [.enabled](#rtv.config.enabled) : <code>boolean</code>
    * [.isTypeset()](#rtv.isTypeset)
37
    * [.fullyQualify()](#rtv.fullyQualify)
Stefan Cameron's avatar
Stefan Cameron committed
38
39
    * [.RtvSuccess()](#rtv.RtvSuccess)
    * [.RtvError()](#rtv.RtvError)
Stefan Cameron's avatar
Stefan Cameron committed
40
41
    * [.check(value, typeset, [options])](#rtv.check)[<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
    * [.verify(value, typeset, [options])](#rtv.verify)[<code>RtvSuccess</code>](#rtvref.RtvSuccess)
42

Stefan Cameron's avatar
Stefan Cameron committed
43
44
45
46
47
<a name="rtv.types"></a>

## rtv.types : [<code>Enumeration</code>](#rtvref.Enumeration)
Enumeration of [types](#rtvref.types.types).

Stefan Cameron's avatar
Stefan Cameron committed
48
49
__For convenience, each type is also available directly from this module__,
 e.g. `STRING`, `FINITE`, etc.
Stefan Cameron's avatar
Stefan Cameron committed
50
51

The Enumeration can be used to perform additional validations (e.g.
Stefan Cameron's avatar
Stefan Cameron committed
52
53
 `types.verify('foo')` would throw because "foo" is not a valid type),
 however whether the type is referenced as `STRING` or `types.STRING`
Stefan Cameron's avatar
Stefan Cameron committed
54
55
 makes no difference to typeset validation.

56
57
**Kind**: static property of [<code>rtv</code>](#rtv)  
**Read only**: true  
Stefan Cameron's avatar
Stefan Cameron committed
58
59
60
61
62
<a name="rtv.qualifiers"></a>

## rtv.qualifiers : [<code>Enumeration</code>](#rtvref.Enumeration)
Enumeration of [qualifiers](#rtvref.qualifiers.qualifiers).

Stefan Cameron's avatar
Stefan Cameron committed
63
64
__For convenience, each qualifier is also available directly from this module__,
 e.g. `EXPECTED`, `OPTIONAL`, etc.
65

Stefan Cameron's avatar
Stefan Cameron committed
66
The Enumeration can be used to perform additional validations (e.g.
Stefan Cameron's avatar
Stefan Cameron committed
67
68
69
 `qualifiers.verify('x')` would throw because "x" is not a valid qualifier),
 however whether the qualifier is referenced as `EXPECTED` or
 `qualifiers.EXPECTED`` makes no difference to typeset validation.
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88

**Kind**: static property of [<code>rtv</code>](#rtv)  
**Read only**: true  
<a name="rtv.version"></a>

## rtv.version : <code>string</code>
Library version.

**Kind**: static property of [<code>rtv</code>](#rtv)  
**Read only**: true  
<a name="rtv.config"></a>

## rtv.config : <code>object</code>
<h3>RTV.js Configuration</h3>

**Kind**: static namespace of [<code>rtv</code>](#rtv)  
<a name="rtv.config.enabled"></a>

### config.enabled : <code>boolean</code>
89
Globally enables or disables [verify](#rtv.verify) and [check](#rtv.check). When set
Stefan Cameron's avatar
Stefan Cameron committed
90
 to `false`, these methods are no-ops and always return success.
91

Stefan Cameron's avatar
Stefan Cameron committed
92
93
94
Use this to enable code optimization when building source with a bundler that supports
 _tree shaking_, like [Rollup](https://rollupjs.org/) or
 [Webpack](https://webpack.js.org/).
95

Stefan Cameron's avatar
Stefan Cameron committed
96
The following plugins can redefine the statement `rtv.config.enabled`
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
 as `false` prior to code optimizations that remove unreachable code:

- Rollup: [rollup-plugin-replace](https://github.com/rollup/rollup-plugin-replace)
- Webpack: [DefinePlugin](https://webpack.js.org/plugins/define-plugin/)

<h4>Enabled Example: Rollup</h4>

By conditionally calling [verify](#rtv.verify) based on the state of
 [enabled](#rtv.config.enabled), a bundler can be configured to completely
 remove the code from a production build.

Given this module code snippet:

<pre><code>...

if (rtv.config.enabled) {
 rtv.verify(jsonResult, expectedShape);
}

Stefan Cameron's avatar
Stefan Cameron committed
116
rtv.config.enabled && rtv.verify(jsonResult, expectedShape); // a bit shorter
117
118
119
120
121
122
123
124
125
126
127
128
129

...
</code></pre>

And using this `rollup.config.js` snippet:

<pre><code>const replacePlugin = require('rollup-plugin-replace');

module.exports = {
  ...
  plugins: [
    // invoke this plugin _before_ any other plugins
    replacePlugin({
Stefan Cameron's avatar
Stefan Cameron committed
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
      'rtv.config.enabled': JSON.stringify(false)
    }),
    ...
  ]
};
</code></pre>

You could also define your own global to achieve the same result:

<pre><code>...
DO_TYPE_CHECKS && rtv.verify(...);
</code></pre>

<pre><code>const replacePlugin = require('rollup-plugin-replace');

module.exports = {
  ...
  plugins: [
    // invoke this plugin _before_ any other plugins
    replacePlugin({
      DO_TYPE_CHECKS: JSON.stringify(false)
151
152
153
154
155
156
157
158
159
    }),
    ...
  ]
};
</code></pre>

The code in the module snippet above would be completely removed from the
 build's output, thereby removing any rtv.js overhead from production.

Stefan Cameron's avatar
Stefan Cameron committed
160
161
162
163
164
If you're using Webpack, be sure to also _not_ explicitly mark the `rtvjs`
 module as an external when disabling RTV.js: Doing so will result in the
 module always being required as an external, even when tree shaking eliminates
 all the code that comes from it.

165
**Kind**: static property of [<code>config</code>](#rtv.config)  
Stefan Cameron's avatar
Stefan Cameron committed
166
167
168
169
170
**See**

- [check](#rtv.check)
- [verify](#rtv.verify)

171
172
173
174
175
176
177
<a name="rtv.isTypeset"></a>

## rtv.isTypeset()
Determines if a value is a typeset.

**Kind**: static method of [<code>rtv</code>](#rtv)  
**See**: [isTypeset](#rtvref.validation.isTypeset)  
178
179
180
181
182
183
184
<a name="rtv.fullyQualify"></a>

## rtv.fullyQualify()
Fully-qualifies a given typeset.

**Kind**: static method of [<code>rtv</code>](#rtv)  
**See**: [fullyQualify](#rtvref.impl.fullyQualify)  
Stefan Cameron's avatar
Stefan Cameron committed
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<a name="rtv.RtvSuccess"></a>

## rtv.RtvSuccess()
Reference to the [RtvSuccess](#rtvref.RtvSuccess) class/constructor.

This can be used to determine, for example, if the result of [rtv.check()](#rtv.check)
 is the success indicator: `if (result instanceof rtv.RtvSuccess) ...` Note that both
 [RtvSuccess](#rtvref.RtvSuccess) and [RtvError](#rtvref.RtvError) have a
 `valid: boolean` property which you can also use to easily test for success or failure.

**Kind**: static method of [<code>rtv</code>](#rtv)  
**See**: [RtvSuccess](#rtvref.RtvSuccess)  
<a name="rtv.RtvError"></a>

## rtv.RtvError()
Reference to the [RtvError](#rtvref.RtvError) class/constructor.

This is useful if you need to determine whether an `Error` is an `RtvError`
 using the `instanceof` operator: `if (err instanceof rtv.RtvError) ...`

**Kind**: static method of [<code>rtv</code>](#rtv)  
**See**: [RtvError](#rtvref.RtvError)  
207
208
<a name="rtv.check"></a>

Stefan Cameron's avatar
Stefan Cameron committed
209
## rtv.check(value, typeset, [options]) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
210
211
212
213
214
215
216
217
Checks a value against a typeset for compliance.

**Kind**: static method of [<code>rtv</code>](#rtv)  
**Returns**: [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError) - Success indicator if the
 `value` is compliant to the `shape`; `RtvError` if not. __Unlike
 [verify()](#rtv.verify), an exception is not thrown__ if the
 `value` is non-compliant.

Stefan Cameron's avatar
Stefan Cameron committed
218
219
220
 Since both [RtvSuccess](#rtvref.RtvSuccess) (returned when
  the check succeeds) as well as [RtvError](#rtvref.RtvError) (returned
  when the check fails) have a `valid: boolean` property in common, it's
221
  easy to test for success/failure like this:
Stefan Cameron's avatar
Stefan Cameron committed
222
  `if (rtv.check(2, rtv.FINITE).valid) {...}`.
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241

 __NOTE:__ This method always returns a success indicator if RTV.js is currently
  [disabled](#rtv.config.enabled).  
**Throws**:

- <code>Error</code> If `typeset` is not a valid typeset.

**See**

- [verify](#rtv.verify)
- [enabled](#rtv.config.enabled)
- [types](#rtvref.types)
- [shape_descriptor](#rtvref.types.shape_descriptor)


| Param | Type | Description |
| --- | --- | --- |
| value | <code>\*</code> | Value to check. |
| typeset | [<code>typeset</code>](#rtvref.types.typeset) | Expected shape of (or typeset describing)  the `value`. A shape is a kind of typeset. Normally, this is a  [shape descriptor](#rtvref.types.shape_descriptor). |
Stefan Cameron's avatar
Stefan Cameron committed
242
| [options] | [<code>type\_validator\_context\_options</code>](#rtvref.validator.type_validator_context_options) | Configuration options. |
243
244
245

<a name="rtv.verify"></a>

Stefan Cameron's avatar
Stefan Cameron committed
246
## rtv.verify(value, typeset, [options]) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess)
247
248
__Requires__ a value to be compliant to a shape.

Stefan Cameron's avatar
Stefan Cameron committed
249
250
 __NOTE:__ This method always returns a success indicator if RTV.js is currently
  [disabled](#rtv.config.enabled).
251
252
253
254
255
256

**Kind**: static method of [<code>rtv</code>](#rtv)  
**Returns**: [<code>RtvSuccess</code>](#rtvref.RtvSuccess) - Success indicator IIF the `value` is compliant
 to the `shape`. Otherwise, an [RtvError](#rtvref.RtvError) __is thrown__.  
**Throws**:

Stefan Cameron's avatar
Stefan Cameron committed
257
- [<code>RtvError</code>](#rtvref.RtvError) If the `value` is not compliant to the `shape`.
258
259
260
261
262
263
264
265
266
267
268
269
270
271
- <code>Error</code> If `typeset` is not a valid typeset.

**See**

- [check](#rtv.check)
- [enabled](#rtv.config.enabled)
- [types](#rtvref.types)
- [shape_descriptor](#rtvref.types.shape_descriptor)


| Param | Type | Description |
| --- | --- | --- |
| value | <code>\*</code> | Value to check. |
| typeset | [<code>typeset</code>](#rtvref.types.typeset) | Expected shape of (or typeset describing)  the `value`. A shape is a kind of typeset. Normally, this is a  [shape descriptor](#rtvref.types.shape_descriptor). |
Stefan Cameron's avatar
Stefan Cameron committed
272
| [options] | [<code>type\_validator\_context\_options</code>](#rtvref.validator.type_validator_context_options) | Configuration options. |
273

274
275
<a name="rtvref"></a>

276
277
# rtvref : <code>object</code>
<h3>RTV.js Reference</h3>
278

279
280
Members herein are _indirectly_ accessed and/or exposed through the
 [RTV.js Public Interface](#rtv).
281

Stefan Cameron's avatar
Stefan Cameron committed
282
**Kind**: global namespace  
283

284
285
* [rtvref](#rtvref) : <code>object</code>
    * [.Enumeration](#rtvref.Enumeration)
286
287
        * [new Enumeration(map, [name])](#new_rtvref.Enumeration_new)
        * [.$name](#rtvref.Enumeration+$name) : <code>string</code>
288
        * [.$values](#rtvref.Enumeration+$values) : <code>Array.&lt;String&gt;</code>
Stefan Cameron's avatar
Stefan Cameron committed
289
        * [.check(value)](#rtvref.Enumeration+check) ⇒ <code>\*</code> \| <code>undefined</code>
290
        * [.verify(value, [silent])](#rtvref.Enumeration+verify) ⇒ <code>\*</code>
291
        * [.toString()](#rtvref.Enumeration+toString) ⇒ <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
292
    * [.RtvError](#rtvref.RtvError) ⇐ [<code>JS\_Error</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
Stefan Cameron's avatar
Stefan Cameron committed
293
        * [new RtvError(value, typeset, path, mismatch, [rootCause])](#new_rtvref.RtvError_new)
294
        * [.valid](#rtvref.RtvError+valid) : <code>boolean</code>
295
296
        * [.value](#rtvref.RtvError+value) : <code>\*</code>
        * [.typeset](#rtvref.RtvError+typeset) : [<code>typeset</code>](#rtvref.types.typeset)
297
        * [.path](#rtvref.RtvError+path) : <code>Array.&lt;string&gt;</code>
Stefan Cameron's avatar
Stefan Cameron committed
298
299
        * [.mismatch](#rtvref.RtvError+mismatch) : [<code>fully\_qualified\_typeset</code>](#rtvref.types.fully_qualified_typeset)
        * [.rootCause](#rtvref.RtvError+rootCause) : <code>Error</code> \| <code>undefined</code>
300
        * [.toString()](#rtvref.RtvError+toString) ⇒ <code>string</code>
301
302
303
304
    * [.RtvSuccess](#rtvref.RtvSuccess)
        * [new RtvSuccess()](#new_rtvref.RtvSuccess_new)
        * [.valid](#rtvref.RtvSuccess+valid) : <code>boolean</code>
        * [.toString()](#rtvref.RtvSuccess+toString) ⇒ <code>string</code>
305
    * [.impl](#rtvref.impl) : <code>object</code>
306
        * [.getQualifier(typeset)](#rtvref.impl.getQualifier) ⇒ <code>string</code>
307
        * [.toTypeset(type, [qualifier], [args], [fullyQualified])](#rtvref.impl.toTypeset) ⇒ [<code>typeset</code>](#rtvref.types.typeset)
Stefan Cameron's avatar
Stefan Cameron committed
308
        * [.fullyQualify(typeset, [qualifier])](#rtvref.impl.fullyQualify) ⇒ [<code>fully\_qualified\_typeset</code>](#rtvref.types.fully_qualified_typeset)
309
        * [.extractNextType(typeset, [qualifier])](#rtvref.impl.extractNextType) ⇒ [<code>typeset</code>](#rtvref.types.typeset) \| <code>Array</code>
Stefan Cameron's avatar
Stefan Cameron committed
310
311
312
        * [.checkWithType(value, singleType, [context])](#rtvref.impl.checkWithType) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
        * [.checkWithShape(value, shape, [context])](#rtvref.impl.checkWithShape) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
        * [.checkWithArray(value, arrayTs, [context])](#rtvref.impl.checkWithArray) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
313
        * [.check(value, typeset, [context])](#rtvref.impl.check) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
314
    * [.qualifiers](#rtvref.qualifiers) : <code>object</code>
Stefan Cameron's avatar
Stefan Cameron committed
315
316
317
318
        * [.REQUIRED](#rtvref.qualifiers.REQUIRED)
        * [.EXPECTED](#rtvref.qualifiers.EXPECTED)
        * [.OPTIONAL](#rtvref.qualifiers.OPTIONAL)
        * [.TRUTHY](#rtvref.qualifiers.TRUTHY)
319
        * [.qualifiers](#rtvref.qualifiers.qualifiers) : [<code>Enumeration</code>](#rtvref.Enumeration)
320
        * [.DEFAULT_QUALIFIER](#rtvref.qualifiers.DEFAULT_QUALIFIER) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
321
322
        * [.valuePermitted(v, [q])](#rtvref.qualifiers.valuePermitted) ⇒ <code>boolean</code>
        * [.restricted_values](#rtvref.qualifiers.restricted_values) : <code>void</code>
323
    * [.types](#rtvref.types) : <code>object</code>
324
325
        * [.objTypes](#rtvref.types.objTypes) : [<code>Enumeration</code>](#rtvref.Enumeration)
        * [.argTypes](#rtvref.types.argTypes) : [<code>Enumeration</code>](#rtvref.Enumeration)
326
        * [.types](#rtvref.types.types) : [<code>Enumeration</code>](#rtvref.Enumeration)
327
        * [.ANY](#rtvref.types.ANY) : <code>string</code>
328
        * [.NULL](#rtvref.types.NULL) : <code>string</code>
329
330
331
332
333
334
        * [.STRING](#rtvref.types.STRING) : <code>string</code>
        * [.BOOLEAN](#rtvref.types.BOOLEAN) : <code>string</code>
        * [.SYMBOL](#rtvref.types.SYMBOL) : <code>string</code>
        * [.NUMBER](#rtvref.types.NUMBER) : <code>string</code>
        * [.FINITE](#rtvref.types.FINITE) : <code>string</code>
        * [.INT](#rtvref.types.INT) : <code>string</code>
335
        * [.SAFE_INT](#rtvref.types.SAFE_INT) : <code>string</code>
336
        * [.FLOAT](#rtvref.types.FLOAT) : <code>string</code>
337
338
339
340
341
342
        * [.FUNCTION](#rtvref.types.FUNCTION) : <code>string</code>
        * [.REGEXP](#rtvref.types.REGEXP) : <code>string</code>
        * [.DATE](#rtvref.types.DATE) : <code>string</code>
        * [.ERROR](#rtvref.types.ERROR) : <code>string</code>
        * [.PROMISE](#rtvref.types.PROMISE) : <code>string</code>
        * [.ARRAY](#rtvref.types.ARRAY) : <code>string</code>
343
344
345
346
        * [.ANY_OBJECT](#rtvref.types.ANY_OBJECT) : <code>string</code>
        * [.OBJECT](#rtvref.types.OBJECT) : <code>string</code>
        * [.PLAIN_OBJECT](#rtvref.types.PLAIN_OBJECT) : <code>string</code>
        * [.CLASS_OBJECT](#rtvref.types.CLASS_OBJECT) : <code>string</code>
347
        * [.HASH_MAP](#rtvref.types.HASH_MAP) : <code>string</code>
348
349
350
351
        * [.MAP](#rtvref.types.MAP) : <code>string</code>
        * [.WEAK_MAP](#rtvref.types.WEAK_MAP) : <code>string</code>
        * [.SET](#rtvref.types.SET) : <code>string</code>
        * [.WEAK_SET](#rtvref.types.WEAK_SET) : <code>string</code>
352
        * [.JSON](#rtvref.types.JSON) : <code>string</code>
353
        * [.DEFAULT_OBJECT_TYPE](#rtvref.types.DEFAULT_OBJECT_TYPE) : <code>string</code>
354
        * [.primitives](#rtvref.types.primitives) : <code>void</code>
Stefan Cameron's avatar
Stefan Cameron committed
355
        * [.falsy_values](#rtvref.types.falsy_values) : <code>void</code>
356
        * [.qualifier_rules](#rtvref.types.qualifier_rules) : <code>void</code>
357
        * [.shape_descriptor](#rtvref.types.shape_descriptor) : <code>Object</code>
358
359
        * [.type_arguments](#rtvref.types.type_arguments) : <code>Object</code>
        * [.STRING_args](#rtvref.types.STRING_args) : <code>Object</code>
360
        * [.SYMBOL_args](#rtvref.types.SYMBOL_args) : <code>Object</code>
361
        * [.numeric_args](#rtvref.types.numeric_args) : <code>Object</code>
362
        * [.shape_object_args](#rtvref.types.shape_object_args) : <code>Object</code>
363
        * [.ARRAY_args](#rtvref.types.ARRAY_args) : <code>Object</code>
364
365
366
        * [.collection_args](#rtvref.types.collection_args) : <code>Object</code>
        * [.typeset](#rtvref.types.typeset) : <code>Object</code> \| <code>string</code> \| <code>Array</code> \| <code>function</code>
        * [.fully_qualified_typeset](#rtvref.types.fully_qualified_typeset) : <code>Array</code>
367
        * [.custom_validator](#rtvref.types.custom_validator) ⇒ <code>\*</code>
368
    * [.util](#rtvref.util) : <code>object</code>
Stefan Cameron's avatar
Stefan Cameron committed
369
        * [.print(printValue, printOptions)](#rtvref.util.print) ⇒ <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
370
        * [.hasOwnProp(obj, prop)](#rtvref.util.hasOwnProp) ⇒ <code>boolean</code>
371
    * [.validation](#rtvref.validation) : <code>object</code>
372
        * [.method(value)](#rtvref.validation.method) ⇒ <code>boolean</code>
373
374
        * [.isAny](#rtvref.validation.isAny) : <code>Module</code>
            * [.type](#rtvref.validation.isAny.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
375
            * [.check(v)](#rtvref.validation.isAny.check) ⇒ <code>boolean</code>
376
377
        * [.isAnyObject](#rtvref.validation.isAnyObject) : <code>Module</code>
            * [.type](#rtvref.validation.isAnyObject.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
378
            * [.check(v)](#rtvref.validation.isAnyObject.check) ⇒ <code>boolean</code>
379
380
        * [.isArray](#rtvref.validation.isArray) : <code>Module</code>
            * [.type](#rtvref.validation.isArray.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
381
            * [.check(v)](#rtvref.validation.isArray.check) ⇒ <code>boolean</code>
382
383
        * [.isBoolean](#rtvref.validation.isBoolean) : <code>Module</code>
            * [.type](#rtvref.validation.isBoolean.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
384
            * [.check(v)](#rtvref.validation.isBoolean.check) ⇒ <code>boolean</code>
385
386
        * [.isClassObject](#rtvref.validation.isClassObject) : <code>Module</code>
            * [.type](#rtvref.validation.isClassObject.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
387
            * [.check(v)](#rtvref.validation.isClassObject.check) ⇒ <code>boolean</code>
388
389
        * [.isCustomValidator](#rtvref.validation.isCustomValidator) : <code>Module</code>
            * [.type](#rtvref.validation.isCustomValidator.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
390
            * [.check(v)](#rtvref.validation.isCustomValidator.check) ⇒ <code>boolean</code>
391
392
        * [.isDate](#rtvref.validation.isDate) : <code>Module</code>
            * [.type](#rtvref.validation.isDate.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
393
            * [.check(v)](#rtvref.validation.isDate.check) ⇒ <code>boolean</code>
394
395
        * [.isError](#rtvref.validation.isError) : <code>Module</code>
            * [.type](#rtvref.validation.isError.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
396
            * [.check(v)](#rtvref.validation.isError.check) ⇒ <code>boolean</code>
Stefan Cameron's avatar
Stefan Cameron committed
397
398
        * [.isFalsy](#rtvref.validation.isFalsy) : <code>Module</code>
            * [.type](#rtvref.validation.isFalsy.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
399
            * [.check(v)](#rtvref.validation.isFalsy.check) ⇒ <code>boolean</code>
400
401
        * [.isFinite](#rtvref.validation.isFinite) : <code>Module</code>
            * [.type](#rtvref.validation.isFinite.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
402
            * [.check(v)](#rtvref.validation.isFinite.check) ⇒ <code>boolean</code>
403
404
        * [.isFloat](#rtvref.validation.isFloat) : <code>Module</code>
            * [.type](#rtvref.validation.isFloat.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
405
            * [.check(v)](#rtvref.validation.isFloat.check) ⇒ <code>boolean</code>
406
407
        * [.isFunction](#rtvref.validation.isFunction) : <code>Module</code>
            * [.type](#rtvref.validation.isFunction.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
408
            * [.check(v)](#rtvref.validation.isFunction.check) ⇒ <code>boolean</code>
409
410
        * [.isHashMap](#rtvref.validation.isHashMap) : <code>Module</code>
            * [.type](#rtvref.validation.isHashMap.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
411
            * [.check(v)](#rtvref.validation.isHashMap.check) ⇒ <code>boolean</code>
412
413
        * [.isInt](#rtvref.validation.isInt) : <code>Module</code>
            * [.type](#rtvref.validation.isInt.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
414
            * [.check(v)](#rtvref.validation.isInt.check) ⇒ <code>boolean</code>
415
416
        * [.isJson](#rtvref.validation.isJson) : <code>Module</code>
            * [.type](#rtvref.validation.isJson.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
417
            * [.check(v)](#rtvref.validation.isJson.check) ⇒ <code>boolean</code>
418
419
        * [.isMap](#rtvref.validation.isMap) : <code>Module</code>
            * [.type](#rtvref.validation.isMap.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
420
            * [.check(v)](#rtvref.validation.isMap.check) ⇒ <code>boolean</code>
421
422
        * [.isNull](#rtvref.validation.isNull) : <code>Module</code>
            * [.type](#rtvref.validation.isNull.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
423
            * [.check(v)](#rtvref.validation.isNull.check) ⇒ <code>boolean</code>
424
425
        * [.isNumber](#rtvref.validation.isNumber) : <code>Module</code>
            * [.type](#rtvref.validation.isNumber.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
426
            * [.check(v)](#rtvref.validation.isNumber.check) ⇒ <code>boolean</code>
427
428
        * [.isObject](#rtvref.validation.isObject) : <code>Module</code>
            * [.type](#rtvref.validation.isObject.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
429
            * [.check(v)](#rtvref.validation.isObject.check) ⇒ <code>boolean</code>
430
431
        * [.isPlainObject](#rtvref.validation.isPlainObject) : <code>Module</code>
            * [.type](#rtvref.validation.isPlainObject.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
432
            * [.check(v)](#rtvref.validation.isPlainObject.check) ⇒ <code>boolean</code>
433
434
        * [.isPrimitive](#rtvref.validation.isPrimitive) : <code>Module</code>
            * [.type](#rtvref.validation.isPrimitive.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
435
            * [.check(v)](#rtvref.validation.isPrimitive.check) ⇒ <code>boolean</code>
436
437
        * [.isPromise](#rtvref.validation.isPromise) : <code>Module</code>
            * [.type](#rtvref.validation.isPromise.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
438
            * [.check(v)](#rtvref.validation.isPromise.check) ⇒ <code>boolean</code>
439
440
        * [.isRegExp](#rtvref.validation.isRegExp) : <code>Module</code>
            * [.type](#rtvref.validation.isRegExp.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
441
            * [.check(v)](#rtvref.validation.isRegExp.check) ⇒ <code>boolean</code>
442
443
        * [.isSafeInt](#rtvref.validation.isSafeInt) : <code>Module</code>
            * [.type](#rtvref.validation.isSafeInt.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
444
            * [.check(v)](#rtvref.validation.isSafeInt.check) ⇒ <code>boolean</code>
445
446
        * [.isSet](#rtvref.validation.isSet) : <code>Module</code>
            * [.type](#rtvref.validation.isSet.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
447
            * [.check(v)](#rtvref.validation.isSet.check) ⇒ <code>boolean</code>
448
449
        * [.isShape](#rtvref.validation.isShape) : <code>Module</code>
            * [.type](#rtvref.validation.isShape.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
450
            * [.check(v)](#rtvref.validation.isShape.check) ⇒ <code>boolean</code>
451
452
        * [.isString](#rtvref.validation.isString) : <code>Module</code>
            * [.type](#rtvref.validation.isString.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
453
            * [.check(v, [options])](#rtvref.validation.isString.check) ⇒ <code>boolean</code>
454
455
        * [.isSymbol](#rtvref.validation.isSymbol) : <code>Module</code>
            * [.type](#rtvref.validation.isSymbol.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
456
            * [.check(v)](#rtvref.validation.isSymbol.check) ⇒ <code>boolean</code>
457
458
        * [.isTypeArgs](#rtvref.validation.isTypeArgs) : <code>Module</code>
            * [.type](#rtvref.validation.isTypeArgs.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
459
            * [.check(v)](#rtvref.validation.isTypeArgs.check) ⇒ <code>boolean</code>
460
461
        * [.isTypeset](#rtvref.validation.isTypeset) : <code>Module</code>
            * [.type](#rtvref.validation.isTypeset.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
462
            * [.check(v, [options])](#rtvref.validation.isTypeset.check) ⇒ <code>boolean</code>
463
464
        * [.isWeakMap](#rtvref.validation.isWeakMap) : <code>Module</code>
            * [.type](#rtvref.validation.isWeakMap.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
465
            * [.check(v)](#rtvref.validation.isWeakMap.check) ⇒ <code>boolean</code>
466
467
        * [.isWeakSet](#rtvref.validation.isWeakSet) : <code>Module</code>
            * [.type](#rtvref.validation.isWeakSet.type) : <code>string</code>
Stefan Cameron's avatar
Stefan Cameron committed
468
            * [.check(v)](#rtvref.validation.isWeakSet.check) ⇒ <code>boolean</code>
469
    * [.validator](#rtvref.validator) : <code>object</code>
470
        * [.type_validator(value, qualifier, args, context)](#rtvref.validator.type_validator) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
471
        * [.validator_config(settings)](#rtvref.validator.validator_config)
472
473
474
        * [.valAny](#rtvref.validator.valAny) : <code>Module</code>
            * [.type](#rtvref.validator.valAny.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valAny.config)
Stefan Cameron's avatar
Stefan Cameron committed
475
            * [.validate(v, [q])](#rtvref.validator.valAny.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
476
477
478
        * [.valAnyObject](#rtvref.validator.valAnyObject) : <code>Module</code>
            * [.type](#rtvref.validator.valAnyObject.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valAnyObject.config)
Stefan Cameron's avatar
Stefan Cameron committed
479
            * [.validate(v, [q], [args], [context])](#rtvref.validator.valAnyObject.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
480
481
482
        * [.valArray](#rtvref.validator.valArray) : <code>Module</code>
            * [.type](#rtvref.validator.valArray.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valArray.config)
Stefan Cameron's avatar
Stefan Cameron committed
483
            * [.validate(v, [q], [args], [context])](#rtvref.validator.valArray.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
484
485
486
        * [.valBoolean](#rtvref.validator.valBoolean) : <code>Module</code>
            * [.type](#rtvref.validator.valBoolean.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valBoolean.config)
Stefan Cameron's avatar
Stefan Cameron committed
487
            * [.validate(v, [q])](#rtvref.validator.valBoolean.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
488
489
490
        * [.valClassObject](#rtvref.validator.valClassObject) : <code>Module</code>
            * [.type](#rtvref.validator.valClassObject.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valClassObject.config)
Stefan Cameron's avatar
Stefan Cameron committed
491
            * [.validate(v, [q], [args], [context])](#rtvref.validator.valClassObject.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
492
493
494
        * [.valDate](#rtvref.validator.valDate) : <code>Module</code>
            * [.type](#rtvref.validator.valDate.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valDate.config)
Stefan Cameron's avatar
Stefan Cameron committed
495
            * [.validate(v, [q])](#rtvref.validator.valDate.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
496
497
498
        * [.valError](#rtvref.validator.valError) : <code>Module</code>
            * [.type](#rtvref.validator.valError.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valError.config)
Stefan Cameron's avatar
Stefan Cameron committed
499
            * [.validate(v, [q])](#rtvref.validator.valError.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
500
501
502
        * [.valFinite](#rtvref.validator.valFinite) : <code>Module</code>
            * [.type](#rtvref.validator.valFinite.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valFinite.config)
Stefan Cameron's avatar
Stefan Cameron committed
503
            * [.validate(v, [q], [args])](#rtvref.validator.valFinite.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
504
505
506
        * [.valFloat](#rtvref.validator.valFloat) : <code>Module</code>
            * [.type](#rtvref.validator.valFloat.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valFloat.config)
Stefan Cameron's avatar
Stefan Cameron committed
507
            * [.validate(v, [q], [args])](#rtvref.validator.valFloat.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
508
509
510
        * [.valFunction](#rtvref.validator.valFunction) : <code>Module</code>
            * [.type](#rtvref.validator.valFunction.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valFunction.config)
Stefan Cameron's avatar
Stefan Cameron committed
511
            * [.validate(v, [q])](#rtvref.validator.valFunction.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
512
513
514
        * [.valHashMap](#rtvref.validator.valHashMap) : <code>Module</code>
            * [.type](#rtvref.validator.valHashMap.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valHashMap.config)
Stefan Cameron's avatar
Stefan Cameron committed
515
            * [.validate(v, [q], [args], [context])](#rtvref.validator.valHashMap.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
516
517
518
        * [.valInt](#rtvref.validator.valInt) : <code>Module</code>
            * [.type](#rtvref.validator.valInt.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valInt.config)
Stefan Cameron's avatar
Stefan Cameron committed
519
            * [.validate(v, [q], [args])](#rtvref.validator.valInt.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
520
521
522
        * [.valJson](#rtvref.validator.valJson) : <code>Module</code>
            * [.type](#rtvref.validator.valJson.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valJson.config)
Stefan Cameron's avatar
Stefan Cameron committed
523
            * [.validate(v, [q])](#rtvref.validator.valJson.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
524
525
526
        * [.valMap](#rtvref.validator.valMap) : <code>Module</code>
            * [.type](#rtvref.validator.valMap.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valMap.config)
Stefan Cameron's avatar
Stefan Cameron committed
527
            * [.validate(v, [q], [args], [context])](#rtvref.validator.valMap.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
528
529
530
        * [.valNull](#rtvref.validator.valNull) : <code>Module</code>
            * [.type](#rtvref.validator.valNull.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valNull.config)
Stefan Cameron's avatar
Stefan Cameron committed
531
            * [.validate(v, [q])](#rtvref.validator.valNull.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
532
533
534
        * [.valNumber](#rtvref.validator.valNumber) : <code>Module</code>
            * [.type](#rtvref.validator.valNumber.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valNumber.config)
Stefan Cameron's avatar
Stefan Cameron committed
535
            * [.validate(v, [q], [args])](#rtvref.validator.valNumber.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
536
537
538
        * [.valObject](#rtvref.validator.valObject) : <code>Module</code>
            * [.type](#rtvref.validator.valObject.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valObject.config)
Stefan Cameron's avatar
Stefan Cameron committed
539
            * [.validate(v, [q], [args], [context])](#rtvref.validator.valObject.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
540
541
542
        * [.valPlainObject](#rtvref.validator.valPlainObject) : <code>Module</code>
            * [.type](#rtvref.validator.valPlainObject.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valPlainObject.config)
Stefan Cameron's avatar
Stefan Cameron committed
543
            * [.validate(v, [q], [args], [context])](#rtvref.validator.valPlainObject.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
544
545
546
        * [.valPromise](#rtvref.validator.valPromise) : <code>Module</code>
            * [.type](#rtvref.validator.valPromise.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valPromise.config)
Stefan Cameron's avatar
Stefan Cameron committed
547
            * [.validate(v, [q])](#rtvref.validator.valPromise.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
548
549
550
        * [.valRegExp](#rtvref.validator.valRegExp) : <code>Module</code>
            * [.type](#rtvref.validator.valRegExp.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valRegExp.config)
Stefan Cameron's avatar
Stefan Cameron committed
551
            * [.validate(v, [q])](#rtvref.validator.valRegExp.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
552
553
554
        * [.valSafeInt](#rtvref.validator.valSafeInt) : <code>Module</code>
            * [.type](#rtvref.validator.valSafeInt.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valSafeInt.config)
Stefan Cameron's avatar
Stefan Cameron committed
555
            * [.validate(v, [q], [args])](#rtvref.validator.valSafeInt.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
556
557
558
        * [.valSet](#rtvref.validator.valSet) : <code>Module</code>
            * [.type](#rtvref.validator.valSet.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valSet.config)
Stefan Cameron's avatar
Stefan Cameron committed
559
            * [.validate(v, [q], [args], [context])](#rtvref.validator.valSet.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
560
561
562
        * [.valString](#rtvref.validator.valString) : <code>Module</code>
            * [.type](#rtvref.validator.valString.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valString.config)
Stefan Cameron's avatar
Stefan Cameron committed
563
            * [.validate(v, [q], [args])](#rtvref.validator.valString.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
564
565
566
        * [.valSymbol](#rtvref.validator.valSymbol) : <code>Module</code>
            * [.type](#rtvref.validator.valSymbol.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valSymbol.config)
Stefan Cameron's avatar
Stefan Cameron committed
567
            * [.validate(v, [q], [args])](#rtvref.validator.valSymbol.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
568
569
570
        * [.valWeakMap](#rtvref.validator.valWeakMap) : <code>Module</code>
            * [.type](#rtvref.validator.valWeakMap.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valWeakMap.config)
Stefan Cameron's avatar
Stefan Cameron committed
571
            * [.validate(v, [q])](#rtvref.validator.valWeakMap.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
572
573
574
        * [.valWeakSet](#rtvref.validator.valWeakSet) : <code>Module</code>
            * [.type](#rtvref.validator.valWeakSet.type) : <code>string</code>
            * [.config(settings)](#rtvref.validator.valWeakSet.config)
Stefan Cameron's avatar
Stefan Cameron committed
575
            * [.validate(v, [q])](#rtvref.validator.valWeakSet.validate) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
Stefan Cameron's avatar
Stefan Cameron committed
576
        * [.type_validator_context_options](#rtvref.validator.type_validator_context_options) : <code>Object</code>
577
        * [.type_validator_context](#rtvref.validator.type_validator_context) : <code>Object</code>
578
        * [.validator_config_settings](#rtvref.validator.validator_config_settings) : <code>Object</code>
579
580
581

<a name="rtvref.Enumeration"></a>

582
## rtvref.Enumeration
583
584
585
**Kind**: static class of [<code>rtvref</code>](#rtvref)  

* [.Enumeration](#rtvref.Enumeration)
586
587
    * [new Enumeration(map, [name])](#new_rtvref.Enumeration_new)
    * [.$name](#rtvref.Enumeration+$name) : <code>string</code>
588
    * [.$values](#rtvref.Enumeration+$values) : <code>Array.&lt;String&gt;</code>
Stefan Cameron's avatar
Stefan Cameron committed
589
    * [.check(value)](#rtvref.Enumeration+check) ⇒ <code>\*</code> \| <code>undefined</code>
590
    * [.verify(value, [silent])](#rtvref.Enumeration+verify) ⇒ <code>\*</code>
591
    * [.toString()](#rtvref.Enumeration+toString) ⇒ <code>string</code>
592
593

<a name="new_rtvref.Enumeration_new"></a>
Stefan Cameron's avatar
Stefan Cameron committed
594

595
### new Enumeration(map, [name])
596
Simple enumeration type. Own-properties on an instance are the keys in the
597
598
 specified `map`, with their associated values. Key names cannot start with
 "$".
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613

<pre><code>const state = new Enumeration({
  READY: 1,
  RUNNING: 2,
  STOPPED: 3,
  COMPLETE: 4
});

state.RUNNING; // 2
state.verify(3); // 3 (returns the value since found in enumeration)
state.verify(5); // ERROR thrown
state.check(3); // 3 (same as verify(3) since found in enumeration)
state.check(5); // undefined (silent failure)
state.$values; // [1, 2, 3, 4] (special non-enumerable own-property)
</code></pre>
614
615
616
617
618

**Throws**:

- <code>Error</code> If `map` is falsy or empty.
- <code>Error</code> If `map` has a key that maps to `undefined`.
619
- <code>Error</code> If `map` contains a duplicate value.
620
621
- <code>Error</code> If `map` has a key that is a restricted property (starts with
 "$").
622
623
624
625
626


| Param | Type | Description |
| --- | --- | --- |
| map | <code>Object.&lt;String, \*&gt;</code> | Object mapping keys to values. Values cannot  be `undefined`. |
627
| [name] | <code>string</code> | Friendly name used to identify this enumeration,  especially in validation error messages. |
628

629
630
<a name="rtvref.Enumeration+$name"></a>

631
### enumeration.$name : <code>string</code>
632
633
634
635
Friendly name (not necessarily unique among all enumeration instances)
 used to identify this enumeration, especially in validation error
 messages. Empty string if not specified during construction.

Stefan Cameron's avatar
Stefan Cameron committed
636
637
638
Note that this own-property is non-enumerable on purpose. Enumerable
 properties on this instance are the keys in this enumeration.

639
640
**Kind**: instance property of [<code>Enumeration</code>](#rtvref.Enumeration)  
**Read only**: true  
641
<a name="rtvref.Enumeration+$values"></a>
642

643
### enumeration.$values : <code>Array.&lt;String&gt;</code>
644
645
646
647
648
List of enumeration values. Values are _references_ to values in this
 enumeration.

Note that this own-property is non-enumerable on purpose. Enumerable
 properties on this instance are the keys in this enumeration.
649

650
**Kind**: instance property of [<code>Enumeration</code>](#rtvref.Enumeration)  
651
652
653
**Read only**: true  
<a name="rtvref.Enumeration+check"></a>

654
### enumeration.check(value) ⇒ <code>\*</code> \| <code>undefined</code>
655
656
657
Checks if a value is in this enumeration.

**Kind**: instance method of [<code>Enumeration</code>](#rtvref.Enumeration)  
Stefan Cameron's avatar
Stefan Cameron committed
658
**Returns**: <code>\*</code> \| <code>undefined</code> - The specified value if it is in this enumeration, or `undefined`
659
660
661
662
663
664
665
 if not. An exception is __not__ thrown if the value is not in this enumeration.  
**See**: [verify](#rtvref.Enumeration+verify)  

| Param | Type | Description |
| --- | --- | --- |
| value | <code>\*</code> | Value to check. Cannot be undefined. |

666
<a name="rtvref.Enumeration+verify"></a>
667

668
### enumeration.verify(value, [silent]) ⇒ <code>\*</code>
669
670
671
Validates a value as being in this enumeration. Throws an exception if the value
 is not in this enumeration, unless `silent` is true.

672
**Kind**: instance method of [<code>Enumeration</code>](#rtvref.Enumeration)  
673
674
**Returns**: <code>\*</code> - The specified value if it is in this enumeration, or `undefined` if
 `silent` is true and the value is not in this enumeration.  
675
676
677
678
679
**Throws**:

- <code>Error</code> If not `silent` and the value is not in this enumeration.

**See**: [check](#rtvref.Enumeration+check)  
680
681
682
683

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| value | <code>\*</code> |  | Value to check. Cannot be undefined. |
684
| [silent] | <code>boolean</code> | <code>false</code> | If truthy, returns `undefined` instead of throwing  an exception if the specified value is not in this enumeration. |
685

686
687
<a name="rtvref.Enumeration+toString"></a>

688
### enumeration.toString() ⇒ <code>string</code>
689
690
691
692
693
694
A string representation of this Enumeration.

**Kind**: instance method of [<code>Enumeration</code>](#rtvref.Enumeration)  
**Returns**: <code>string</code> - String representation.  
<a name="rtvref.RtvError"></a>

Stefan Cameron's avatar
Stefan Cameron committed
695
## rtvref.RtvError ⇐ [<code>JS\_Error</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
696
**Kind**: static class of [<code>rtvref</code>](#rtvref)  
Stefan Cameron's avatar
Stefan Cameron committed
697
**Extends**: [<code>JS\_Error</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)  
698

Stefan Cameron's avatar
Stefan Cameron committed
699
* [.RtvError](#rtvref.RtvError) ⇐ [<code>JS\_Error</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
Stefan Cameron's avatar
Stefan Cameron committed
700
    * [new RtvError(value, typeset, path, mismatch, [rootCause])](#new_rtvref.RtvError_new)
701
    * [.valid](#rtvref.RtvError+valid) : <code>boolean</code>
702
703
    * [.value](#rtvref.RtvError+value) : <code>\*</code>
    * [.typeset](#rtvref.RtvError+typeset) : [<code>typeset</code>](#rtvref.types.typeset)
704
    * [.path](#rtvref.RtvError+path) : <code>Array.&lt;string&gt;</code>
Stefan Cameron's avatar
Stefan Cameron committed
705
706
    * [.mismatch](#rtvref.RtvError+mismatch) : [<code>fully\_qualified\_typeset</code>](#rtvref.types.fully_qualified_typeset)
    * [.rootCause](#rtvref.RtvError+rootCause) : <code>Error</code> \| <code>undefined</code>
707
708
709
710
    * [.toString()](#rtvref.RtvError+toString) ⇒ <code>string</code>

<a name="new_rtvref.RtvError_new"></a>

Stefan Cameron's avatar
Stefan Cameron committed
711
### new RtvError(value, typeset, path, mismatch, [rootCause])
712
713
Runtime Verification Error Indicator

714
Describes a failed runtime verification of a value against a given
715
 [shape](#rtvref.types.shape_descriptor) or [typeset](#rtvref.types.typeset)
716
717
718
719
 (note that a shape is a type of typeset).

**Throws**:

Stefan Cameron's avatar
Stefan Cameron committed
720
- <code>Error</code> If `typeset`, `path`, or `mismatch` is invalid.
721
722
723
724
725
726


| Param | Type | Description |
| --- | --- | --- |
| value | <code>\*</code> | The value being verified. |
| typeset | [<code>typeset</code>](#rtvref.types.typeset) | The typeset used for verification. |
727
| path | <code>Array.&lt;string&gt;</code> | The path deep into `value` where the failure occurred.  An empty array signifies the _root_ (top-level) value that was checked. |
Stefan Cameron's avatar
Stefan Cameron committed
728
729
| mismatch | [<code>fully\_qualified\_typeset</code>](#rtvref.types.fully_qualified_typeset) | The fully qualified typeset  that resulted in the failed validation. This is normally the fully-qualified version  of `typeset`, but could be a subtype if `typeset` is an Array typeset or a  [shape descriptor](#rtvref.types.shape_descriptor). |
| [rootCause] | [<code>RtvError</code>](#rtvref.RtvError) \| <code>Error</code> | [Custom Validator](#rtvref.types.custom_validator)  error, if the `RtvError` is a result of a failed custom validation and the validator threw an  exception; or some other nested error that was the root cause for the failed validation. |
730
731
732

<a name="rtvref.RtvError+valid"></a>

733
### rtvError.valid : <code>boolean</code>
734
Flag indicating the validation failed. Always `false`.
735

736
737
**Kind**: instance property of [<code>RtvError</code>](#rtvref.RtvError)  
**Read only**: true  
738
**See**: [valid](#rtvref.RtvSuccess+valid)  
739
740
<a name="rtvref.RtvError+value"></a>

741
### rtvError.value : <code>\*</code>
742
743
Value that failed verification against the
 [typeset](#rtvref.RtvError+typeset).
744
745
746
747
748

**Kind**: instance property of [<code>RtvError</code>](#rtvref.RtvError)  
**Read only**: true  
<a name="rtvref.RtvError+typeset"></a>

749
### rtvError.typeset : [<code>typeset</code>](#rtvref.types.typeset)
750
751
752
753
754
755
Reference to the typeset used for verification.

**Kind**: instance property of [<code>RtvError</code>](#rtvref.RtvError)  
**Read only**: true  
<a name="rtvref.RtvError+path"></a>

756
### rtvError.path : <code>Array.&lt;string&gt;</code>
757
758
759
Path from [value](#rtvref.RtvError+value) to the nested property that
 caused the failure.

Stefan Cameron's avatar
Stefan Cameron committed
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
Note that paths into collections such as [HASH_MAP](#rtvref.types.HASH_MAP)
 or ES6 structures such as [MAP](#rtvref.types.MAP), where it's possible
 to specify arguments to verify keys vs values, will have elements with special
 prefixes to differentiate whether the path points to a key ("`key={key-name}`")
 or a value ("`valueKey={key-name}`").

For example, given the has map `{hello: 'world'}`, if all keys were supposed to be
 numerical, then the path for the validation error would be `["key=hello"]`, indicating
 that the problem occurred with the __key__ named "hello", not the associated __value__.

If, however, keys could be anything, but values had to be numerical, then the path
 would be `["valueKey=hello"]`, indicating that the problem occurred with the __value__
 associated to the key rather than the key itself.

<h4>SECURITY</h4>

Some collection types, such as [MAP](#rtvref.types.MAP) and
777
778
779
780
781
782
 [SET](#rtvref.types.SET), can have actual objects as keys or elements,
 and these are used (in JSON-stringified form) as part of the error path.
 If these objects happen to contain sensitive information, that information
 may end-up in the path, and the path gets included in this error's
 `message` property, which may get logged by your systems.

Stefan Cameron's avatar
Stefan Cameron committed
783
784
785
786
787
788
789
Other object types where keys can technically be any string value could also
 contain sensitive information depending on how these keys are defined. These
 keys will also end-up in the path that gets included in this error's `message`
 property.

__It is YOUR responsibility to exercise necessary caution when validating
 data structures containing sensitive data.__
790
791
792

**Kind**: instance property of [<code>RtvError</code>](#rtvref.RtvError)  
**Read only**: true  
Stefan Cameron's avatar
Stefan Cameron committed
793
<a name="rtvref.RtvError+mismatch"></a>
794

Stefan Cameron's avatar
Stefan Cameron committed
795
796
797
798
799
### rtvError.mismatch : [<code>fully\_qualified\_typeset</code>](#rtvref.types.fully_qualified_typeset)
[Fully qualified typeset](#rtvref.types.fully_qualified_typeset) that caused the
 validation error (i.e. the mismatched subtype). This will be a subset/subtype of the
 [typeset](#rtvref.RtvError+typeset), and possibly of a nested typeset within it,
 expressing only the direct cause of the error.
800

Stefan Cameron's avatar
Stefan Cameron committed
801
For example, of `typeset` is `[[rtv.STRING]]` (a required array of required strings),
Stefan Cameron's avatar
Stefan Cameron committed
802
 and `value` is `['a', 2]`, this property would be `[rtv.REQUIRED, rtv.STRING]`
Stefan Cameron's avatar
Stefan Cameron committed
803
804
805
806
 because the validation error would ultimately have been caused by the nested
 `rtv.STRING` typeset.

Remember that the fully-qualified `typeset` would be
Stefan Cameron's avatar
Stefan Cameron committed
807
 `[rtv.REQUIRED, rtv.ARRAY, {$: [rtv.REQUIRED, rtv.STRING]}]`, which demonstrates
Stefan Cameron's avatar
Stefan Cameron committed
808
 that `[rtv.REQUIRED, rtv.STRING]` is indeed a subset/subtype.
809

Stefan Cameron's avatar
Stefan Cameron committed
810
811
812
813
814
**Kind**: instance property of [<code>RtvError</code>](#rtvref.RtvError)  
**Read only**: true  
<a name="rtvref.RtvError+rootCause"></a>

### rtvError.rootCause : <code>Error</code> \| <code>undefined</code>
815
816
Validation error thrown by a [Custom Validator](#rtvref.types.custom_validator),
 which resulted in this `RtvError`. `undefined` if this error was not the result
817
 of a failed custom validation. If the custom validator throws an error, this will
Stefan Cameron's avatar
Stefan Cameron committed
818
819
820
 be a reference to the error it threw; otherwise, it'll be a generic `Error`
 generated by the library.

821
822
**Kind**: instance property of [<code>RtvError</code>](#rtvref.RtvError)  
**Read only**: true  
823
824
<a name="rtvref.RtvError+toString"></a>

825
### rtvError.toString() ⇒ <code>string</code>
826
827
828
829
A string representation of this instance.

**Kind**: instance method of [<code>RtvError</code>](#rtvref.RtvError)  
**Returns**: <code>string</code> - String representation.  
830
831
<a name="rtvref.RtvSuccess"></a>

832
## rtvref.RtvSuccess
833
834
835
836
837
838
839
840
841
**Kind**: static class of [<code>rtvref</code>](#rtvref)  

* [.RtvSuccess](#rtvref.RtvSuccess)
    * [new RtvSuccess()](#new_rtvref.RtvSuccess_new)
    * [.valid](#rtvref.RtvSuccess+valid) : <code>boolean</code>
    * [.toString()](#rtvref.RtvSuccess+toString) ⇒ <code>string</code>

<a name="new_rtvref.RtvSuccess_new"></a>

842
### new RtvSuccess()
843
844
845
Runtime Verification Success Indicator

Describes a successful runtime verification of a value against a given
846
 [shape](#rtvref.types.shape_descriptor) or [typeset](#rtvref.types.typeset)
847
848
849
850
 (note that a shape is a type of typeset).

<a name="rtvref.RtvSuccess+valid"></a>

851
### rtvSuccess.valid : <code>boolean</code>
852
853
854
855
Flag indicating the validation succeeded. Always `true`.

**Kind**: instance property of [<code>RtvSuccess</code>](#rtvref.RtvSuccess)  
**Read only**: true  
856
**See**: [valid](#rtvref.RtvError+valid)  
857
858
<a name="rtvref.RtvSuccess+toString"></a>

859
### rtvSuccess.toString() ⇒ <code>string</code>
860
861
862
863
A string representation of this instance.

**Kind**: instance method of [<code>RtvSuccess</code>](#rtvref.RtvSuccess)  
**Returns**: <code>string</code> - String representation.  
864
865
<a name="rtvref.impl"></a>

866
867
## rtvref.impl : <code>object</code>
<h3>RTV.js Implementation</h3>
868
869
870
871
872
873
874

Provides the internal implementation for the externally-facing [RTV](#rtv)
 API, as well as utilities for [type validators](#rtvref.validator).

**Kind**: static namespace of [<code>rtvref</code>](#rtvref)  

* [.impl](#rtvref.impl) : <code>object</code>
875
    * [.getQualifier(typeset)](#rtvref.impl.getQualifier) ⇒ <code>string</code>
876
    * [.toTypeset(type, [qualifier], [args], [fullyQualified])](#rtvref.impl.toTypeset) ⇒ [<code>typeset</code>](#rtvref.types.typeset)
Stefan Cameron's avatar
Stefan Cameron committed
877
    * [.fullyQualify(typeset, [qualifier])](#rtvref.impl.fullyQualify) ⇒ [<code>fully\_qualified\_typeset</code>](#rtvref.types.fully_qualified_typeset)
878
    * [.extractNextType(typeset, [qualifier])](#rtvref.impl.extractNextType) ⇒ [<code>typeset</code>](#rtvref.types.typeset) \| <code>Array</code>
Stefan Cameron's avatar
Stefan Cameron committed
879
880
881
    * [.checkWithType(value, singleType, [context])](#rtvref.impl.checkWithType) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
    * [.checkWithShape(value, shape, [context])](#rtvref.impl.checkWithShape) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
    * [.checkWithArray(value, arrayTs, [context])](#rtvref.impl.checkWithArray) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
882
    * [.check(value, typeset, [context])](#rtvref.impl.check) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
883

884
885
<a name="rtvref.impl.getQualifier"></a>

886
### impl.getQualifier(typeset) ⇒ <code>string</code>
887
888
Get the qualifier given any kind of typeset.

889
890
891
892
The typeset's validity is __not__ checked. The function attempts to get a
 qualifier, and defaults to the [default qualifier](qualifiers.DEFAULT_QUALIFIER)
 if it cannot.

893
894
**Kind**: static method of [<code>impl</code>](#rtvref.impl)  
**Returns**: <code>string</code> - The applicable [qualifier](#rtvref.qualifiers) for the
895
 specified typeset, which is assumed to be valid.  
896
897
898
899
900

| Param | Type | Description |
| --- | --- | --- |
| typeset | [<code>typeset</code>](#rtvref.types.typeset) | The typeset in question. |

901
902
<a name="rtvref.impl.toTypeset"></a>

903
### impl.toTypeset(type, [qualifier], [args], [fullyQualified]) ⇒ [<code>typeset</code>](#rtvref.types.typeset)
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
Convert a type, qualifier, and args into a typeset.

While the `qualifier`, `args`, and `fullyQualified` parameters are all
 optional and may be omitted, their order must be maintained: If needed,
 the `qualifier` must always be before `args`, and `args` before
 `fullyQualified`. Parameters with `undefined` values will be ignored.

**Kind**: static method of [<code>impl</code>](#rtvref.impl)  
**Returns**: [<code>typeset</code>](#rtvref.types.typeset) - The simplest typeset that represents the
 combination of the specified type, qualifier, and args, unless `fullyQualified`
 was set to `true`, in which case it'll always be an array typeset and
 fully-qualified.  
**Throws**:

- <code>Error</code> If `type`, `qualifier`, or `args` is invalid.


| Param | Type | Default | Description |
| --- | --- | --- | --- |
| type | <code>string</code> |  | A single type from [types](#rtvref.types.types). |
| [qualifier] | <code>string</code> \| <code>Object</code> \| <code>boolean</code> | <code>&quot;rtvref.qualifiers.DEFAULT_QUALIFIER&quot;</code> | Optional qualifier from [qualifiers](#rtvref.qualifiers.qualifiers). Can also be  either the `args` parameter, or the `fullyQualified` parameter if the  default qualifier is being used. |
| [args] | <code>Object</code> \| <code>boolean</code> |  | Optional  [type arguments](#rtvref.types.type_arguments). If specified, this  parameter must be an [object](#rtvref.types.OBJECT), however the  properties of the object are not validated against the specified `type`  (i.e. they are not guaranteed to be valid for that type). Can also be  the `fullyQualified` parameter if type arguments aren't applicable. |
| [fullyQualified] | <code>boolean</code> | <code>false</code> | If _truthy_, the generated typeset  will always be [fully-qualified](#rtvref.types.fully_qualified_typeset).  Otherwise, it'll be the simplest typeset possible. |

928
929
<a name="rtvref.impl.fullyQualify"></a>

Stefan Cameron's avatar
Stefan Cameron committed
930
### impl.fullyQualify(typeset, [qualifier]) ⇒ [<code>fully\_qualified\_typeset</code>](#rtvref.types.fully_qualified_typeset)
931
932
933
934
935
936
Fully-qualifies a typeset, shallow (i.e. the first level only; nested typesets
 are not fully-qualified).

This function does not modify the input `typeset`.

**Kind**: static method of [<code>impl</code>](#rtvref.impl)  
Stefan Cameron's avatar
Stefan Cameron committed
937
**Returns**: [<code>fully\_qualified\_typeset</code>](#rtvref.types.fully_qualified_typeset) - A new, fully-qualified typeset
938
939
940
941
942
 representing the input `typeset`. Only the first/immediate level of the
 input typeset is fully-qualified. The new array returned contains references
 to elements within the input typeset.  
**Throws**:

943
- <code>Error</code> If `typeset` or `qualifier` is not a valid.
944
945


946
947
948
| Param | Type | Description |
| --- | --- | --- |
| typeset | [<code>typeset</code>](#rtvref.types.typeset) | Typeset to fully-qualify. |
949
| [qualifier] | [<code>qualifiers</code>](#rtvref.qualifiers) | Optional qualifier to be used.  If the typeset is a simple [type](#rtvref.types),   a [shape](#rtvref.types.shape_descriptor), or   a [custom validator](#rtvref.types.custom_validator) that was   cherry-picked out of a typeset whose qualifier should be used instead of   the [default](#rtvref.qualifiers.DEFAULT_QUALIFIER) one.  If `typeset` is an Array typeset, specifying this parameter will __override__   the typeset's qualifier (otherwise, its own qualifier will be used). |
950
951
952

<a name="rtvref.impl.extractNextType"></a>

953
### impl.extractNextType(typeset, [qualifier]) ⇒ [<code>typeset</code>](#rtvref.types.typeset) \| <code>Array</code>
954
955
956
Extracts (modifies) the next complete type from an Array typeset.

For example, if the given `typeset` is `[EXPECTED, STRING, {string_args}, FINITE]`,
957
 the returned array would be `[EXPECTED, STRING, {string_args}]` and `typeset`
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
 would then be `[FINITE]`.

**Kind**: static method of [<code>impl</code>](#rtvref.impl)  
**Returns**: [<code>typeset</code>](#rtvref.types.typeset) \| <code>Array</code> - The extracted __Array typeset__ as a
 new Array, which is a sub-type of the given `typeset`. This sub-typeset is
 not necessarily fully-qualified. If `typeset` was an empty array, an empty
 array is returned (which is the only case where an invalid Array typeset
 is tolerated, so that this function is easy to use in loops, checking for
 the stopping condition where the returned sub-typeset is empty).  
**Throws**:

- <code>Error</code> If `typeset` is not empty and not a valid Array typeset.
- <code>Error</code> If `qualifier` is specified but not valid.


| Param | Type | Description |
| --- | --- | --- |
| typeset | [<code>typeset</code>](#rtvref.types.typeset) \| <code>Array</code> | An Array typeset from which to  extract the next complete type. __This Array will be modified.__ Can also  be an empty array (which is not a valid typeset, but is tolerated; see the  return value for more information). |
| [qualifier] | [<code>qualifiers</code>](#rtvref.qualifiers) \| <code>boolean</code> | Optional, and can either  be a valid qualifier, `true`, or `false`.  <h4>Parameter is specified, and is a qualifier</h4>  If __a qualifier is not found in `typeset`__, this qualifier will be used to  qualify the returned sub-type Array typeset. If a qualifier is found in `typeset`,  this parameter is ignored. If a qualifier is __not__ found in `typeset` and  this parameter is specified, then this qualifier will be used to qualify the  returned sub-type Array typeset.  __Examples:__  - `typeset = [EXPECTED, STRING, FINITE];`  - `extractNextType(typeset, REQUIRED) === [EXPECTED, STRING]`, `typeset === [FINITE]`  - `extractNextType(typeset) === [FINITE]`, `typeset === []`  - `typeset = [FINITE];`  - `extractNextType(typeset, EXPECTED) === [EXPECTED, FINITE]`  <h4>Parameter is specified, and is a boolean</h4>  If `true`, the qualifier, if any, will be included in the returned sub-type  Array typeset.  If `false`, the qualifier, if any, will be ignored.  __Examples:__  - `extractNextType([STRING], true) === [STRING]`  - `extractNextType([REQUIRED, STRING], true) === [EXPECTED, STRING]`  - `extractNextType([REQUIRED, STRING], false) === [STRING]` |
977

978
<a name="rtvref.impl.checkWithType"></a>
979

Stefan Cameron's avatar
Stefan Cameron committed
980
### impl.checkWithType(value, singleType, [context]) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
981
Checks a value using a single type.
982
983
984
985
986
987

**Kind**: static method of [<code>impl</code>](#rtvref.impl)  
**Returns**: [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError) - A success indicator if the
 `value` is compliant to the type; an error indicator if not.  
**Throws**:

988
- <code>Error</code> If `singleType` is not a valid simple type or single type.
Stefan Cameron's avatar
Stefan Cameron committed
989
- <code>Error</code> If the specified `context` is not valid.
990
991
992
993
994
995

**See**: [types](#rtvref.types)  

| Param | Type | Description |
| --- | --- | --- |
| value | <code>\*</code> | Value to check. |
996
| singleType | <code>string</code> \| <code>Array</code> \| <code>Object</code> | Either a simple type name (one of  [types](#rtvref.types.types)), a [shape descriptor](#rtvref.types.shape_descriptor),  or an Array [typeset](#rtvref.types.typeset) which represents a single type.  In the string/simple case, the   [default qualifier](#rtvref.qualifiers.DEFAULT_QUALIFIER) is assumed.  In the shape descriptor case, the   [default object type](#rtvref.types.DEFAULT_OBJECT_TYPE) is assumed.  In the Array case, the qualifier is optional, and a type, along with args,   if any, is expected (e.g. `[type]`, `[qualifier, type]`, `[type, args]`, or   `[qualifier, type, args]`). Note that the type may be implied if the shorthand   notation is being used for an ARRAY, or if the   [default object type](#rtvref.types.DEFAULT_OBJECT_TYPE) is being implied   for a shape, e.g. `[{foo: rtv.STRING}]`.  NOTE: A [custom validator](#rtvref.types.custom_validator) is not considered   a valid single type. It's also considered a __separate type__ if it were passed-in   via an Array, e.g. `[STRING, validator]`, which would violate the fact that   `singleType` should be one type, and therefore cause an exception to be thrown. |
997
| [context] | [<code>type\_validator\_context</code>](#rtvref.validator.type_validator_context) \| <code>undefined</code> | Additional  context for the check. If _falsy_, a new context will be created for all  downstream checks using `value` as the original value, and `undefined` as  the parent. |
998

999
<a name="rtvref.impl.checkWithShape"></a>
1000

Stefan Cameron's avatar
Stefan Cameron committed
1001
### impl.checkWithShape(value, shape, [context]) ⇒ [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError)
1002
Checks a value using a [shape descriptor](#rtvref.types.shape_descriptor) and
1003
1004
1005
1006
1007
1008
1009
1010
 ensure the value's type is the default object type.

**Kind**: static method of [<code>impl</code>](#rtvref.impl)  
**Returns**: [<code>RtvSuccess</code>](#rtvref.RtvSuccess) \| [<code>RtvError</code>](#rtvref.RtvError) - A success indicator if the
 `value` is compliant to the shape; an error indicator if not.  
**Throws**:

- <code>Error</code> If `shape` is not an [OBJECT](#rtvref.types.OBJECT).
Stefan Cameron's avatar
Stefan Cameron committed
1011
- <code>Error</code> If the specified `context` is not valid.
1012
1013
1014
1015
1016
1017


| Param | Type | Description |
| --- | --- | --- |
| value | <code>Object</code> | Value to check. Must be of the  [default](#rtvref.types.DEFAULT_OBJECT_TYPE) object type. |
| shape | <code>Object</code> | Expected shape of the `value`. Must be an  [OBJECT](#rtvref.types.OBJECT). |
Stefan Cameron's avatar
Stefan Cameron committed
1018
| [context] | [<code>type\_validator\_context</code>](#rtvref.validator.type_validator_context) \| <code>undefined</code> | Additional  context for the check. If _falsy_, a new context will be created for all  downstream checks using `value` as the original value, and an empty/root path. |