From 42a42cff301b62d61eae6766d26036b058264075 Mon Sep 17 00:00:00 2001 From: Stefan Cameron Date: Tue, 18 Sep 2018 19:28:04 -0500 Subject: [PATCH] Beautify and fix the API documentation * Fix INT -> SAFE_INT * Remove completed TODOs * Clarify example titles * Fix missing rtvref.validation and rtvref.validator docs Also rename `validation/isValidator -> validation/isCustomValidator` to avoid confusion between custom validators in typesets, and type validators in the library. * Clarify rtv.t and rtv.q enumerations * Clean-up the rtv interface --- API.md | 3492 ++++++++++++++--- README.md | 7 +- package.json | 2 +- src/lib/impl.js | 51 +- src/lib/lib.jsdoc | 8 + src/lib/qualifiers.js | 11 +- src/lib/types.js | 94 +- src/lib/util.js | 7 +- src/lib/validation/isAny.js | 5 + src/lib/validation/isAnyObject.js | 5 + src/lib/validation/isArray.js | 5 + src/lib/validation/isBoolean.js | 5 + src/lib/validation/isClassObject.js | 5 + .../{isValidator.js => isCustomValidator.js} | 15 +- src/lib/validation/isDate.js | 5 + src/lib/validation/isError.js | 5 + src/lib/validation/isFinite.js | 5 + src/lib/validation/isFloat.js | 5 + src/lib/validation/isFunction.js | 5 + src/lib/validation/isHashMap.js | 5 + src/lib/validation/isInt.js | 5 + src/lib/validation/isJson.js | 5 + src/lib/validation/isMap.js | 5 + src/lib/validation/isNull.js | 7 +- src/lib/validation/isNumber.js | 5 + src/lib/validation/isObject.js | 5 + src/lib/validation/isPlainObject.js | 5 + src/lib/validation/isPrimitive.js | 5 + src/lib/validation/isPromise.js | 5 + src/lib/validation/isRegExp.js | 5 + src/lib/validation/isSafeInt.js | 5 + src/lib/validation/isSet.js | 5 + src/lib/validation/isShape.js | 5 + src/lib/validation/isString.js | 5 + src/lib/validation/isSymbol.js | 5 + src/lib/validation/isTypeArgs.js | 5 + src/lib/validation/isTypeset.js | 13 +- src/lib/validation/isWeakMap.js | 5 + src/lib/validation/isWeakSet.js | 5 + src/lib/validation/validation.jsdoc | 2 +- src/lib/validator/valAny.js | 7 +- src/lib/validator/valAnyObject.js | 7 +- src/lib/validator/valArray.js | 7 +- src/lib/validator/valBoolean.js | 7 +- src/lib/validator/valClassObject.js | 7 +- src/lib/validator/valDate.js | 7 +- src/lib/validator/valError.js | 7 +- src/lib/validator/valFinite.js | 7 +- src/lib/validator/valFloat.js | 7 +- src/lib/validator/valFunction.js | 7 +- src/lib/validator/valHashMap.js | 7 +- src/lib/validator/valInt.js | 7 +- src/lib/validator/valJson.js | 7 +- src/lib/validator/valMap.js | 7 +- src/lib/validator/valNull.js | 7 +- src/lib/validator/valNumber.js | 7 +- src/lib/validator/valObject.js | 7 +- src/lib/validator/valPlainObject.js | 7 +- src/lib/validator/valPromise.js | 7 +- src/lib/validator/valRegExp.js | 7 +- src/lib/validator/valSafeInt.js | 7 +- src/lib/validator/valSet.js | 7 +- src/lib/validator/valString.js | 7 +- src/lib/validator/valSymbol.js | 7 +- src/lib/validator/valWeakMap.js | 7 +- src/lib/validator/valWeakSet.js | 7 +- src/lib/validator/validator.jsdoc | 8 +- src/rtv.js | 162 +- test/lib/RtvError.test.js | 2 +- test/lib/RtvSuccess.test.js | 2 +- test/lib/impl.test.js | 4 +- test/lib/types.test.js | 6 +- test/lib/validation/isValidator.test.js | 6 +- test/rtv.test.js | 67 +- tools/internals.js | 4 +- 75 files changed, 3450 insertions(+), 842 deletions(-) create mode 100644 src/lib/lib.jsdoc rename src/lib/validation/{isValidator.js => isCustomValidator.js} (52%) diff --git a/API.md b/API.md index 1bcd5d5..bfb0c14 100644 --- a/API.md +++ b/API.md @@ -1,24 +1,212 @@ -## Objects +# Objects
-
rtvref : object
-

RTV.js Reference

+
rtv : object
+

RTV.js Public Interface

-

Members herein are indirectly exposed through the rtv object.

+

Provides the externally-facing API. It wraps the + implementation, adding a bit of syntactic sugar, and + adds the configuration facilities.

-
rtv : object
-

RTV.js

+
rtvref : object
+

RTV.js Reference

-

Runtime Verification Library for browsers and Node.js.

+

Members herein are indirectly accessed and/or exposed through the + RTV.js Public Interface.

+ + +# rtv : object +

RTV.js Public Interface

+ +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) : object + * [.t](#rtv.t) : [Enumeration](#rtvref.Enumeration) + * [.q](#rtv.q) : [Enumeration](#rtvref.Enumeration) + * [.e](#rtv.e) : boolean + * [.version](#rtv.version) : string + * [.config](#rtv.config) : object + * [.enabled](#rtv.config.enabled) : boolean + * [.isTypeset()](#rtv.isTypeset) + * [.check(value, typeset)](#rtv.check) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.verify(value, typeset)](#rtv.verify) ⇒ [RtvSuccess](#rtvref.RtvSuccess) + + + +## rtv.t : [Enumeration](#rtvref.Enumeration) +Enumeration of [types](#rtvref.types.types). + +**Kind**: static property of [rtv](#rtv) +**Read only**: true + + +## rtv.q : [Enumeration](#rtvref.Enumeration) +Enumeration of [qualifiers](#rtvref.qualifiers.qualifiers). + +**Kind**: static property of [rtv](#rtv) +**Read only**: true + + +## rtv.e : boolean +Shortcut proxy for reading [enabled](#rtv.config.enabled). + +**Kind**: static property of [rtv](#rtv) +**Read only**: true + + +## rtv.version : string +Library version. + +**Kind**: static property of [rtv](#rtv) +**Read only**: true + + +## rtv.config : object +

RTV.js Configuration

+ +**Kind**: static namespace of [rtv](#rtv) + + +### config.enabled : boolean +Globally enables or disables [verify](#rtv.verify) and [check](#rtv.check). + +Use this, or the shortcut [e](#rtv.e), 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/). + +The following plugins can redefine the statement `rtv.e` or `rtv.config.enabled` + 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/) + +

Enabled Example: Rollup

+ +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: + +
...
+
+if (rtv.config.enabled) {
+ rtv.verify(jsonResult, expectedShape);
+}
+
+rtv.e && rtv.verify(jsonResult, expectedShape); // shorter
+
+...
+
+ +And using this `rollup.config.js` snippet: + +
const replacePlugin = require('rollup-plugin-replace');
+
+module.exports = {
+  ...
+  plugins: [
+    // invoke this plugin _before_ any other plugins
+    replacePlugin({
+      'rtv.e': 'false',
+      'rtv.config.enabled': 'false'
+    }),
+    ...
+  ]
+};
+
+ +The code in the module snippet above would be completely removed from the + build's output, thereby removing any rtv.js overhead from production. + +**Kind**: static property of [config](#rtv.config) +**See**: [rtv.enabled](rtv.enabled) + + +## rtv.isTypeset() +Determines if a value is a typeset. + +**Kind**: static method of [rtv](#rtv) +**See**: [isTypeset](#rtvref.validation.isTypeset) + + +## rtv.check(value, typeset) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +Checks a value against a typeset for compliance. + +**Kind**: static method of [rtv](#rtv) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#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. + + 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 + easy to test for success/failure like this: + `if (rtv.check(2, rtv.t.FINITE).valid) {...}`. + + __NOTE:__ This method always returns a success indicator if RTV.js is currently + [disabled](#rtv.config.enabled). +**Throws**: + +- Error 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 | \* | Value to check. | +| typeset | [typeset](#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). | + + + +## rtv.verify(value, typeset) ⇒ [RtvSuccess](#rtvref.RtvSuccess) +__Requires__ a value to be compliant to a shape. + +NOTE: This method does nothing if RTV.js is currently + [disabled](#rtv.config.enabled). + +**Kind**: static method of [rtv](#rtv) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) - Success indicator IIF the `value` is compliant + to the `shape`. Otherwise, an [RtvError](#rtvref.RtvError) __is thrown__. +**Throws**: + +- RtvError If the `value` is not compliant to the `shape`. +- Error 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 | \* | Value to check. | +| typeset | [typeset](#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). | + -## rtvref : object -

RTV.js Reference

+# rtvref : object +

RTV.js Reference

-Members herein are _indirectly_ exposed through the [rtv](#rtv) object. +Members herein are _indirectly_ accessed and/or exposed through the + [RTV.js Public Interface](#rtv). **Kind**: global namespace @@ -48,9 +236,9 @@ Members herein are _indirectly_ exposed through the [rtv](#rtv) object. * [.toTypeset(type, [qualifier], [args], [fullyQualified])](#rtvref.impl.toTypeset) ⇒ [typeset](#rtvref.types.typeset) * [.fullyQualify(typeset, [qualifier])](#rtvref.impl.fullyQualify) ⇒ [fully_qualified_typeset](#rtvref.types.fully_qualified_typeset) * [.extractNextType(typeset, [qualifier])](#rtvref.impl.extractNextType) ⇒ [typeset](#rtvref.types.typeset) \| Array - * [.checkType(value, singleType)](#rtvref.impl.checkType) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - * [.checkShape(value, shape)](#rtvref.impl.checkShape) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - * [.checkTypeset(value, typeset)](#rtvref.impl.checkTypeset) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.checkWithType(value, singleType)](#rtvref.impl.checkWithType) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.checkWithShape(value, shape)](#rtvref.impl.checkWithShape) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.checkWithArray(value, array)](#rtvref.impl.checkWithArray) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) * [.check(value, typeset)](#rtvref.impl.check) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) * [.qualifiers](#rtvref.qualifiers) : object * [.qualifiers](#rtvref.qualifiers.qualifiers) : [Enumeration](#rtvref.Enumeration) @@ -58,7 +246,7 @@ Members herein are _indirectly_ exposed through the [rtv](#rtv) object. * [.EXPECTED](#rtvref.qualifiers.EXPECTED) : string * [.OPTIONAL](#rtvref.qualifiers.OPTIONAL) : string * [.DEFAULT_QUALIFIER](#rtvref.qualifiers.DEFAULT_QUALIFIER) : string - * [.checkBasicRules(v, [q])](#rtvref.qualifiers.checkBasicRules) ⇒ boolean + * [.nilPermitted(v, [q])](#rtvref.qualifiers.nilPermitted) ⇒ boolean * [.types](#rtvref.types) : object * [.objTypes](#rtvref.types.objTypes) : [Enumeration](#rtvref.Enumeration) * [.argTypes](#rtvref.types.argTypes) : [Enumeration](#rtvref.Enumeration) @@ -71,7 +259,7 @@ Members herein are _indirectly_ exposed through the [rtv](#rtv) object. * [.NUMBER](#rtvref.types.NUMBER) : string * [.FINITE](#rtvref.types.FINITE) : string * [.INT](#rtvref.types.INT) : string - * [.INT](#rtvref.types.INT) : string + * [.SAFE_INT](#rtvref.types.SAFE_INT) : string * [.FLOAT](#rtvref.types.FLOAT) : string * [.FUNCTION](#rtvref.types.FUNCTION) : string * [.REGEXP](#rtvref.types.REGEXP) : string @@ -90,8 +278,8 @@ Members herein are _indirectly_ exposed through the [rtv](#rtv) object. * [.WEAK_SET](#rtvref.types.WEAK_SET) : string * [.JSON](#rtvref.types.JSON) : string * [.DEFAULT_OBJECT_TYPE](#rtvref.types.DEFAULT_OBJECT_TYPE) : string - * [.primitives](#rtvref.types.primitives) : \* - * [.rules](#rtvref.types.rules) : \* + * [.primitives](#rtvref.types.primitives) : void + * [.qualifier_rules](#rtvref.types.qualifier_rules) : void * [.shape_descriptor](#rtvref.types.shape_descriptor) : Object * [.type_arguments](#rtvref.types.type_arguments) : Object * [.STRING_args](#rtvref.types.STRING_args) : Object @@ -103,19 +291,215 @@ Members herein are _indirectly_ exposed through the [rtv](#rtv) object. * [.typeset](#rtvref.types.typeset) : Object \| string \| Array \| function * [.fully_qualified_typeset](#rtvref.types.fully_qualified_typeset) : Array * [.custom_validator](#rtvref.types.custom_validator) : function + * [.util](#rtvref.util) : object + * [.print(printValue)](#rtvref.util.print) ⇒ string * [.validation](#rtvref.validation) : object * [.method(value)](#rtvref.validation.method) ⇒ boolean + * [.isAny](#rtvref.validation.isAny) : Module + * [.type](#rtvref.validation.isAny.type) : string + * [.default(v)](#rtvref.validation.isAny.default) ⇒ boolean + * [.isAnyObject](#rtvref.validation.isAnyObject) : Module + * [.type](#rtvref.validation.isAnyObject.type) : string + * [.default(v)](#rtvref.validation.isAnyObject.default) ⇒ boolean + * [.isArray](#rtvref.validation.isArray) : Module + * [.type](#rtvref.validation.isArray.type) : string + * [.default(v)](#rtvref.validation.isArray.default) ⇒ boolean + * [.isBoolean](#rtvref.validation.isBoolean) : Module + * [.type](#rtvref.validation.isBoolean.type) : string + * [.default(v)](#rtvref.validation.isBoolean.default) ⇒ boolean + * [.isClassObject](#rtvref.validation.isClassObject) : Module + * [.type](#rtvref.validation.isClassObject.type) : string + * [.default(v)](#rtvref.validation.isClassObject.default) ⇒ boolean + * [.isCustomValidator](#rtvref.validation.isCustomValidator) : Module + * [.type](#rtvref.validation.isCustomValidator.type) : string + * [.default(v)](#rtvref.validation.isCustomValidator.default) ⇒ boolean + * [.isDate](#rtvref.validation.isDate) : Module + * [.type](#rtvref.validation.isDate.type) : string + * [.default(v)](#rtvref.validation.isDate.default) ⇒ boolean + * [.isError](#rtvref.validation.isError) : Module + * [.type](#rtvref.validation.isError.type) : string + * [.default(v)](#rtvref.validation.isError.default) ⇒ boolean + * [.isFinite](#rtvref.validation.isFinite) : Module + * [.type](#rtvref.validation.isFinite.type) : string + * [.default(v)](#rtvref.validation.isFinite.default) ⇒ boolean + * [.isFloat](#rtvref.validation.isFloat) : Module + * [.type](#rtvref.validation.isFloat.type) : string + * [.default(v)](#rtvref.validation.isFloat.default) ⇒ boolean + * [.isFunction](#rtvref.validation.isFunction) : Module + * [.type](#rtvref.validation.isFunction.type) : string + * [.default(v)](#rtvref.validation.isFunction.default) ⇒ boolean + * [.isHashMap](#rtvref.validation.isHashMap) : Module + * [.type](#rtvref.validation.isHashMap.type) : string + * [.default(v)](#rtvref.validation.isHashMap.default) ⇒ boolean + * [.isInt](#rtvref.validation.isInt) : Module + * [.type](#rtvref.validation.isInt.type) : string + * [.default(v)](#rtvref.validation.isInt.default) ⇒ boolean + * [.isJson](#rtvref.validation.isJson) : Module + * [.type](#rtvref.validation.isJson.type) : string + * [.default(v)](#rtvref.validation.isJson.default) ⇒ boolean + * [.isMap](#rtvref.validation.isMap) : Module + * [.type](#rtvref.validation.isMap.type) : string + * [.default(v)](#rtvref.validation.isMap.default) ⇒ boolean + * [.isNull](#rtvref.validation.isNull) : Module + * [.type](#rtvref.validation.isNull.type) : string + * [.default(v)](#rtvref.validation.isNull.default) ⇒ boolean + * [.isNumber](#rtvref.validation.isNumber) : Module + * [.type](#rtvref.validation.isNumber.type) : string + * [.default(v)](#rtvref.validation.isNumber.default) ⇒ boolean + * [.isObject](#rtvref.validation.isObject) : Module + * [.type](#rtvref.validation.isObject.type) : string + * [.default(v)](#rtvref.validation.isObject.default) ⇒ boolean + * [.isPlainObject](#rtvref.validation.isPlainObject) : Module + * [.type](#rtvref.validation.isPlainObject.type) : string + * [.default(v)](#rtvref.validation.isPlainObject.default) ⇒ boolean + * [.isPrimitive](#rtvref.validation.isPrimitive) : Module + * [.type](#rtvref.validation.isPrimitive.type) : string + * [.default(v)](#rtvref.validation.isPrimitive.default) ⇒ boolean + * [.isPromise](#rtvref.validation.isPromise) : Module + * [.type](#rtvref.validation.isPromise.type) : string + * [.default(v)](#rtvref.validation.isPromise.default) ⇒ boolean + * [.isRegExp](#rtvref.validation.isRegExp) : Module + * [.type](#rtvref.validation.isRegExp.type) : string + * [.default(v)](#rtvref.validation.isRegExp.default) ⇒ boolean + * [.isSafeInt](#rtvref.validation.isSafeInt) : Module + * [.type](#rtvref.validation.isSafeInt.type) : string + * [.default(v)](#rtvref.validation.isSafeInt.default) ⇒ boolean + * [.isSet](#rtvref.validation.isSet) : Module + * [.type](#rtvref.validation.isSet.type) : string + * [.default(v)](#rtvref.validation.isSet.default) ⇒ boolean + * [.isShape](#rtvref.validation.isShape) : Module + * [.type](#rtvref.validation.isShape.type) : string + * [.default(v)](#rtvref.validation.isShape.default) ⇒ boolean + * [.isString](#rtvref.validation.isString) : Module + * [.type](#rtvref.validation.isString.type) : string + * [.default(v, [options])](#rtvref.validation.isString.default) ⇒ boolean + * [.isSymbol](#rtvref.validation.isSymbol) : Module + * [.type](#rtvref.validation.isSymbol.type) : string + * [.default(v)](#rtvref.validation.isSymbol.default) ⇒ boolean + * [.isTypeArgs](#rtvref.validation.isTypeArgs) : Module + * [.type](#rtvref.validation.isTypeArgs.type) : string + * [.default(v)](#rtvref.validation.isTypeArgs.default) ⇒ boolean + * [.isTypeset](#rtvref.validation.isTypeset) : Module + * [.type](#rtvref.validation.isTypeset.type) : string + * [.default(v, [options])](#rtvref.validation.isTypeset.default) ⇒ boolean + * [.isWeakMap](#rtvref.validation.isWeakMap) : Module + * [.type](#rtvref.validation.isWeakMap.type) : string + * [.default(v)](#rtvref.validation.isWeakMap.default) ⇒ boolean + * [.isWeakSet](#rtvref.validation.isWeakSet) : Module + * [.type](#rtvref.validation.isWeakSet.type) : string + * [.default(v)](#rtvref.validation.isWeakSet.default) ⇒ boolean * [.validator](#rtvref.validator) : object * [.type_validator(value, [qualifier], [args])](#rtvref.validator.type_validator) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) * [.validator_config(settings)](#rtvref.validator.validator_config) + * [.valAny](#rtvref.validator.valAny) : Module + * [.type](#rtvref.validator.valAny.type) : string + * [.config(settings)](#rtvref.validator.valAny.config) + * [.default(v, [q])](#rtvref.validator.valAny.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valAnyObject](#rtvref.validator.valAnyObject) : Module + * [.type](#rtvref.validator.valAnyObject.type) : string + * [.config(settings)](#rtvref.validator.valAnyObject.config) + * [.default(v, [q], [args])](#rtvref.validator.valAnyObject.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valArray](#rtvref.validator.valArray) : Module + * [.type](#rtvref.validator.valArray.type) : string + * [.config(settings)](#rtvref.validator.valArray.config) + * [.default(v, [q], [args])](#rtvref.validator.valArray.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valBoolean](#rtvref.validator.valBoolean) : Module + * [.type](#rtvref.validator.valBoolean.type) : string + * [.config(settings)](#rtvref.validator.valBoolean.config) + * [.default(v, [q])](#rtvref.validator.valBoolean.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valClassObject](#rtvref.validator.valClassObject) : Module + * [.type](#rtvref.validator.valClassObject.type) : string + * [.config(settings)](#rtvref.validator.valClassObject.config) + * [.default(v, [q], [args])](#rtvref.validator.valClassObject.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valDate](#rtvref.validator.valDate) : Module + * [.type](#rtvref.validator.valDate.type) : string + * [.config(settings)](#rtvref.validator.valDate.config) + * [.default(v, [q])](#rtvref.validator.valDate.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valError](#rtvref.validator.valError) : Module + * [.type](#rtvref.validator.valError.type) : string + * [.config(settings)](#rtvref.validator.valError.config) + * [.default(v, [q])](#rtvref.validator.valError.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valFinite](#rtvref.validator.valFinite) : Module + * [.type](#rtvref.validator.valFinite.type) : string + * [.config(settings)](#rtvref.validator.valFinite.config) + * [.default(v, [q], [args])](#rtvref.validator.valFinite.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valFloat](#rtvref.validator.valFloat) : Module + * [.type](#rtvref.validator.valFloat.type) : string + * [.config(settings)](#rtvref.validator.valFloat.config) + * [.default(v, [q], [args])](#rtvref.validator.valFloat.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valFunction](#rtvref.validator.valFunction) : Module + * [.type](#rtvref.validator.valFunction.type) : string + * [.config(settings)](#rtvref.validator.valFunction.config) + * [.default(v, [q])](#rtvref.validator.valFunction.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valHashMap](#rtvref.validator.valHashMap) : Module + * [.type](#rtvref.validator.valHashMap.type) : string + * [.config(settings)](#rtvref.validator.valHashMap.config) + * [.default(v, [q], [args])](#rtvref.validator.valHashMap.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valInt](#rtvref.validator.valInt) : Module + * [.type](#rtvref.validator.valInt.type) : string + * [.config(settings)](#rtvref.validator.valInt.config) + * [.default(v, [q], [args])](#rtvref.validator.valInt.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valJson](#rtvref.validator.valJson) : Module + * [.type](#rtvref.validator.valJson.type) : string + * [.config(settings)](#rtvref.validator.valJson.config) + * [.default(v, [q])](#rtvref.validator.valJson.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valMap](#rtvref.validator.valMap) : Module + * [.type](#rtvref.validator.valMap.type) : string + * [.config(settings)](#rtvref.validator.valMap.config) + * [.default(v, [q], [args])](#rtvref.validator.valMap.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valNull](#rtvref.validator.valNull) : Module + * [.type](#rtvref.validator.valNull.type) : string + * [.config(settings)](#rtvref.validator.valNull.config) + * [.default(v, [q])](#rtvref.validator.valNull.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valNumber](#rtvref.validator.valNumber) : Module + * [.type](#rtvref.validator.valNumber.type) : string + * [.config(settings)](#rtvref.validator.valNumber.config) + * [.default(v, [q], [args])](#rtvref.validator.valNumber.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valObject](#rtvref.validator.valObject) : Module + * [.type](#rtvref.validator.valObject.type) : string + * [.config(settings)](#rtvref.validator.valObject.config) + * [.default(v, [q], [args])](#rtvref.validator.valObject.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valPlainObject](#rtvref.validator.valPlainObject) : Module + * [.type](#rtvref.validator.valPlainObject.type) : string + * [.config(settings)](#rtvref.validator.valPlainObject.config) + * [.default(v, [q], [args])](#rtvref.validator.valPlainObject.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valPromise](#rtvref.validator.valPromise) : Module + * [.type](#rtvref.validator.valPromise.type) : string + * [.config(settings)](#rtvref.validator.valPromise.config) + * [.default(v, [q])](#rtvref.validator.valPromise.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valRegExp](#rtvref.validator.valRegExp) : Module + * [.type](#rtvref.validator.valRegExp.type) : string + * [.config(settings)](#rtvref.validator.valRegExp.config) + * [.default(v, [q])](#rtvref.validator.valRegExp.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valSafeInt](#rtvref.validator.valSafeInt) : Module + * [.type](#rtvref.validator.valSafeInt.type) : string + * [.config(settings)](#rtvref.validator.valSafeInt.config) + * [.default(v, [q], [args])](#rtvref.validator.valSafeInt.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valSet](#rtvref.validator.valSet) : Module + * [.type](#rtvref.validator.valSet.type) : string + * [.config(settings)](#rtvref.validator.valSet.config) + * [.default(v, [q], [args])](#rtvref.validator.valSet.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valString](#rtvref.validator.valString) : Module + * [.type](#rtvref.validator.valString.type) : string + * [.config(settings)](#rtvref.validator.valString.config) + * [.default(v, [q], [args])](#rtvref.validator.valString.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valSymbol](#rtvref.validator.valSymbol) : Module + * [.type](#rtvref.validator.valSymbol.type) : string + * [.config(settings)](#rtvref.validator.valSymbol.config) + * [.default(v, [q], [args])](#rtvref.validator.valSymbol.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valWeakMap](#rtvref.validator.valWeakMap) : Module + * [.type](#rtvref.validator.valWeakMap.type) : string + * [.config(settings)](#rtvref.validator.valWeakMap.config) + * [.default(v, [q])](#rtvref.validator.valWeakMap.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valWeakSet](#rtvref.validator.valWeakSet) : Module + * [.type](#rtvref.validator.valWeakSet.type) : string + * [.config(settings)](#rtvref.validator.valWeakSet.config) + * [.default(v, [q])](#rtvref.validator.valWeakSet.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) * [.validator_config_settings](#rtvref.validator.validator_config_settings) : Object - -* * * - -### rtvref.Enumeration +## rtvref.Enumeration **Kind**: static class of [rtvref](#rtvref) * [.Enumeration](#rtvref.Enumeration) @@ -126,12 +510,9 @@ Members herein are _indirectly_ exposed through the [rtv](#rtv) object. * [.verify(value, [silent])](#rtvref.Enumeration+verify) ⇒ \* * [.toString()](#rtvref.Enumeration+toString) ⇒ string - -* * * - -#### new Enumeration(map, [name]) +### new Enumeration(map, [name]) Simple enumeration type. Own-properties on an instance are the keys in the specified `map`, with their associated values. Key names cannot start with "$". @@ -165,24 +546,18 @@ state.$values; // [1, 2, 3, 4] (special non-enumerable own-property) | map | Object.<String, \*> | Object mapping keys to values. Values cannot be `undefined`. | | [name] | string | Friendly name used to identify this enumeration, especially in validation error messages. | - -* * * - -#### enumeration.$name : string +### enumeration.$name : string 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. **Kind**: instance property of [Enumeration](#rtvref.Enumeration) **Read only**: true - -* * * - -#### enumeration.$values : Array.<String> +### enumeration.$values : Array.<String> List of enumeration values. Values are _references_ to values in this enumeration. @@ -191,12 +566,9 @@ Note that this own-property is non-enumerable on purpose. Enumerable **Kind**: instance property of [Enumeration](#rtvref.Enumeration) **Read only**: true - -* * * - -#### enumeration.check(value) ⇒ \* \| undefined +### enumeration.check(value) ⇒ \* \| undefined Checks if a value is in this enumeration. **Kind**: instance method of [Enumeration](#rtvref.Enumeration) @@ -208,12 +580,9 @@ Checks if a value is in this enumeration. | --- | --- | --- | | value | \* | Value to check. Cannot be undefined. | - -* * * - -#### enumeration.verify(value, [silent]) ⇒ \* +### enumeration.verify(value, [silent]) ⇒ \* Validates a value as being in this enumeration. Throws an exception if the value is not in this enumeration, unless `silent` is true. @@ -231,22 +600,16 @@ Validates a value as being in this enumeration. Throws an exception if the value | value | \* | | Value to check. Cannot be undefined. | | [silent] | boolean | false | If truthy, returns `undefined` instead of throwing an exception if the specified value is not in this enumeration. | - -* * * - -#### enumeration.toString() ⇒ string +### enumeration.toString() ⇒ string A string representation of this Enumeration. **Kind**: instance method of [Enumeration](#rtvref.Enumeration) **Returns**: string - String representation. - -* * * - -### rtvref.RtvError ⇐ [JS_Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) +## rtvref.RtvError ⇐ [JS_Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) **Kind**: static class of [rtvref](#rtvref) **Extends**: [JS_Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) @@ -260,12 +623,9 @@ A string representation of this Enumeration. * [.failure](#rtvref.RtvError+failure) : Error \| undefined * [.toString()](#rtvref.RtvError+toString) ⇒ string - -* * * - -#### new RtvError(value, typeset, path, cause, [failure]) +### new RtvError(value, typeset, path, cause, [failure]) Runtime Verification Error Indicator Describes a failed runtime verification of a value against a given @@ -285,54 +645,39 @@ Describes a failed runtime verification of a value against a given | cause | [fully_qualified_typeset](#rtvref.types.fully_qualified_typeset) | The fully qualified typeset that caused the failure. This is normally the fully-qualified version of `typeset`, but could be a sub-type if `typeset` is an Array typeset or a [shape descriptor](#rtvref.types.shape_descriptor). | | [failure] | Error | [Custom Validator](#rtvref.types.custom_validator) error, if the `RtvError` is a result of a failed custom validation. | - -* * * - -#### rtvError.valid : boolean +### rtvError.valid : boolean Flag indicating the validation failed. Always `false`. **Kind**: instance property of [RtvError](#rtvref.RtvError) **Read only**: true **See**: [valid](#rtvref.RtvSuccess+valid) - -* * * - -#### rtvError.value : \* +### rtvError.value : \* Value that failed verification. **Kind**: instance property of [RtvError](#rtvref.RtvError) **Read only**: true - -* * * - -#### rtvError.typeset : [typeset](#rtvref.types.typeset) +### rtvError.typeset : [typeset](#rtvref.types.typeset) Reference to the typeset used for verification. **Kind**: instance property of [RtvError](#rtvref.RtvError) **Read only**: true - -* * * - -#### rtvError.path : Array.<string> +### rtvError.path : Array.<string> Path from `value` to the nested property that caused the failure. This is a shallow clone of the original `path` specified. **Kind**: instance property of [RtvError](#rtvref.RtvError) **Read only**: true - -* * * - -#### rtvError.cause : [fully_qualified_typeset](#rtvref.types.fully_qualified_typeset) +### rtvError.cause : [fully_qualified_typeset](#rtvref.types.fully_qualified_typeset) Fully qualified typeset that caused the failure. This will be a subset of `typeset`, and possibly of a nested typeset within `typeset` expressing only the direct cause of the failure. @@ -344,34 +689,25 @@ If `typeset` is `[[rtv.t.STRING]]` (a required array of required strings), **Kind**: instance property of [RtvError](#rtvref.RtvError) **Read only**: true - -* * * - -#### rtvError.failure : Error \| undefined +### rtvError.failure : Error \| undefined Validation error thrown by a [Custom Validator](#rtvref.types.custom_validator), which resulted in this `RtvError`. `undefined` if this error was not the result of a failed custom validation. **Kind**: instance property of [RtvError](#rtvref.RtvError) **Read only**: true - -* * * - -#### rtvError.toString() ⇒ string +### rtvError.toString() ⇒ string A string representation of this instance. **Kind**: instance method of [RtvError](#rtvref.RtvError) **Returns**: string - String representation. - -* * * - -### rtvref.RtvSuccess +## rtvref.RtvSuccess **Kind**: static class of [rtvref](#rtvref) * [.RtvSuccess](#rtvref.RtvSuccess) @@ -379,46 +715,34 @@ A string representation of this instance. * [.valid](#rtvref.RtvSuccess+valid) : boolean * [.toString()](#rtvref.RtvSuccess+toString) ⇒ string - -* * * - -#### new RtvSuccess() +### new RtvSuccess() Runtime Verification Success Indicator Describes a successful runtime verification of a value against a given [shape](#rtvref.types.shape_descriptor) or [typeset](#rtvref.types.typeset) (note that a shape is a type of typeset). - -* * * - -#### rtvSuccess.valid : boolean +### rtvSuccess.valid : boolean Flag indicating the validation succeeded. Always `true`. **Kind**: instance property of [RtvSuccess](#rtvref.RtvSuccess) **Read only**: true **See**: [valid](#rtvref.RtvError+valid) - -* * * - -#### rtvSuccess.toString() ⇒ string +### rtvSuccess.toString() ⇒ string A string representation of this instance. **Kind**: instance method of [RtvSuccess](#rtvref.RtvSuccess) **Returns**: string - String representation. - -* * * - -### rtvref.impl : object -

RTV Implementation Module

+## rtvref.impl : object +

RTV.js Implementation

Provides the internal implementation for the externally-facing [RTV](#rtv) API, as well as utilities for [type validators](#rtvref.validator). @@ -430,17 +754,14 @@ Provides the internal implementation for the externally-facing [RTV](#rtv) * [.toTypeset(type, [qualifier], [args], [fullyQualified])](#rtvref.impl.toTypeset) ⇒ [typeset](#rtvref.types.typeset) * [.fullyQualify(typeset, [qualifier])](#rtvref.impl.fullyQualify) ⇒ [fully_qualified_typeset](#rtvref.types.fully_qualified_typeset) * [.extractNextType(typeset, [qualifier])](#rtvref.impl.extractNextType) ⇒ [typeset](#rtvref.types.typeset) \| Array - * [.checkType(value, singleType)](#rtvref.impl.checkType) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - * [.checkShape(value, shape)](#rtvref.impl.checkShape) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - * [.checkTypeset(value, typeset)](#rtvref.impl.checkTypeset) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.checkWithType(value, singleType)](#rtvref.impl.checkWithType) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.checkWithShape(value, shape)](#rtvref.impl.checkWithShape) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.checkWithArray(value, array)](#rtvref.impl.checkWithArray) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) * [.check(value, typeset)](#rtvref.impl.check) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - -* * * - -#### impl.getQualifier(typeset) ⇒ string +### impl.getQualifier(typeset) ⇒ string Get the qualifier given any kind of typeset. The typeset's validity is __not__ checked. The function attempts to get a @@ -455,12 +776,9 @@ The typeset's validity is __not__ checked. The function attempts to get a | --- | --- | --- | | typeset | [typeset](#rtvref.types.typeset) | The typeset in question. | - -* * * - -#### impl.toTypeset(type, [qualifier], [args], [fullyQualified]) ⇒ [typeset](#rtvref.types.typeset) +### impl.toTypeset(type, [qualifier], [args], [fullyQualified]) ⇒ [typeset](#rtvref.types.typeset) Convert a type, qualifier, and args into a typeset. While the `qualifier`, `args`, and `fullyQualified` parameters are all @@ -485,12 +803,9 @@ While the `qualifier`, `args`, and `fullyQualified` parameters are all | [args] | Object \| boolean | | 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] | boolean | false | If _truthy_, the generated typeset will always be [fully-qualified](#rtvref.types.fully_qualified_typeset). Otherwise, it'll be the simplest typeset possible. | - -* * * - -#### impl.fullyQualify(typeset, [qualifier]) ⇒ [fully_qualified_typeset](#rtvref.types.fully_qualified_typeset) +### impl.fullyQualify(typeset, [qualifier]) ⇒ [fully_qualified_typeset](#rtvref.types.fully_qualified_typeset) Fully-qualifies a typeset, shallow (i.e. the first level only; nested typesets are not fully-qualified). @@ -511,12 +826,9 @@ This function does not modify the input `typeset`. | typeset | [typeset](#rtvref.types.typeset) | Typeset to fully-qualify. | | [qualifier] | [qualifiers](#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). | - -* * * - -#### impl.extractNextType(typeset, [qualifier]) ⇒ [typeset](#rtvref.types.typeset) \| Array +### impl.extractNextType(typeset, [qualifier]) ⇒ [typeset](#rtvref.types.typeset) \| Array Extracts (modifies) the next complete type from an Array typeset. For example, if the given `typeset` is `[EXPECTED, STRING, {string_args}, FINITE]`, @@ -541,12 +853,9 @@ For example, if the given `typeset` is `[EXPECTED, STRING, {string_args}, FINITE | typeset | [typeset](#rtvref.types.typeset) \| Array | 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] | [qualifiers](#rtvref.qualifiers) \| boolean | Optional, and can either be a valid qualifier, `true`, or `false`.

Parameter is specified, and is a qualifier

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]`

Parameter is specified, and is a boolean

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]` | + -* * * - - - -#### impl.checkType(value, singleType) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +### impl.checkWithType(value, singleType) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) Checks a value using a single type. **Kind**: static method of [impl](#rtvref.impl) @@ -563,12 +872,9 @@ Checks a value using a single type. | value | \* | Value to check. | | singleType | [typeset](#rtvref.types.typeset) | Either a simple type name (one of [types](#rtvref.types.types)), a [shape descriptor](#rtvref.types.shape_descriptor), or an Array typeset which represents a single type. A [custom validator](#rtvref.types.custom_validator) is not considered a valid 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 the shorthand notation is being used for an ARRAY, or if the [default object type](#rtvref.types.DEFAULT_OBJECT_TYPE) is being implied. | + -* * * - - - -#### impl.checkShape(value, shape) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +### impl.checkWithShape(value, shape) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) Checks a value using a [shape descriptor](#rtvref.types.shape_descriptor) and ensure the value's type is the default object type. @@ -585,12 +891,9 @@ Checks a value using a [shape descriptor](#rtvref.types.shape_descriptor) and | value | Object | Value to check. Must be of the [default](#rtvref.types.DEFAULT_OBJECT_TYPE) object type. | | shape | Object | Expected shape of the `value`. Must be an [OBJECT](#rtvref.types.OBJECT). | + -* * * - - - -#### impl.checkTypeset(value, typeset) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +### impl.checkWithArray(value, array) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) Checks a value using an Array typeset. **Kind**: static method of [impl](#rtvref.impl) @@ -605,14 +908,11 @@ Checks a value using an Array typeset. | Param | Type | Description | | --- | --- | --- | | value | \* | Value to check. | -| typeset | [typeset](#rtvref.types.typeset) | The Array typeset to check against. | - - -* * * +| array | Array | The Array [typeset](#rtvref.types.typeset) to check against. | -#### impl.check(value, typeset) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +### impl.check(value, typeset) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) Checks a value against a typeset. **Kind**: static method of [impl](#rtvref.impl) @@ -629,13 +929,10 @@ Checks a value against a typeset. | value | \* | Value to check. | | typeset | [typeset](#rtvref.types.typeset) | Expected shape/type of the value. | - -* * * - -### rtvref.qualifiers : object -

Qualifiers

+## rtvref.qualifiers : object +

Qualifiers

Qualifiers determine the degree at which a value must be of a given type. @@ -647,23 +944,21 @@ Qualifiers determine the degree at which a value must be of a given type. * [.EXPECTED](#rtvref.qualifiers.EXPECTED) : string * [.OPTIONAL](#rtvref.qualifiers.OPTIONAL) : string * [.DEFAULT_QUALIFIER](#rtvref.qualifiers.DEFAULT_QUALIFIER) : string - * [.checkBasicRules(v, [q])](#rtvref.qualifiers.checkBasicRules) ⇒ boolean - - -* * * + * [.nilPermitted(v, [q])](#rtvref.qualifiers.nilPermitted) ⇒ boolean -#### qualifiers.qualifiers : [Enumeration](#rtvref.Enumeration) -Enumeration (`string -> string`) of [qualifiers](#rtvref.qualifiers). - -**Kind**: static property of [qualifiers](#rtvref.qualifiers) +### qualifiers.qualifiers : [Enumeration](#rtvref.Enumeration) +Enumeration (`string -> string`) of all qualifiers: -* * * +- [REQUIRED](#rtvref.qualifiers.REQUIRED) +- [EXPECTED](#rtvref.qualifiers.EXPECTED) +- [OPTIONAL](#rtvref.qualifiers.OPTIONAL) +**Kind**: static property of [qualifiers](#rtvref.qualifiers) -#### qualifiers.REQUIRED : string +### qualifiers.REQUIRED : string Required qualifier: The value __must__ be of the expected type. Depending on the type, additional requirements may be enforced. @@ -685,12 +980,9 @@ See specific type for additional rules. - [types](#rtvref.types) - [STRING](#rtvref.types.STRING) - -* * * - -#### qualifiers.EXPECTED : string +### qualifiers.EXPECTED : string Expected qualifier: The value _should_ be of the expected type. Depending on the type, additional requirements may be enforced. @@ -712,12 +1004,9 @@ See specific type for additional rules. - [types](#rtvref.types) - [STRING](#rtvref.types.STRING) - -* * * - -#### qualifiers.OPTIONAL : string +### qualifiers.OPTIONAL : string Optional qualifier: The value _may_ be of the expected type. Depending on the type, additional requirements may be enforced. @@ -732,21 +1021,15 @@ See specific type for additional rules. **Kind**: static constant of [qualifiers](#rtvref.qualifiers) **See**: [types](#rtvref.types) - -* * * - -#### qualifiers.DEFAULT_QUALIFIER : string +### qualifiers.DEFAULT_QUALIFIER : string Default qualifier: [REQUIRED](#rtvref.qualifiers.REQUIRED) **Kind**: static constant of [qualifiers](#rtvref.qualifiers) + -* * * - - - -#### qualifiers.checkBasicRules(v, [q]) ⇒ boolean +### qualifiers.nilPermitted(v, [q]) ⇒ boolean Convenience function to check if a nil value (either `undefined` or `null`) is permitted under basic qualifier rules: @@ -767,13 +1050,10 @@ Convenience function to check if a nil value (either `undefined` or `null`) | v | \* | Value to check. | | [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | - -* * * - -### rtvref.types : object -

Types

+## rtvref.types : object +

Types

**Kind**: static namespace of [rtvref](#rtvref) @@ -789,7 +1069,7 @@ Convenience function to check if a nil value (either `undefined` or `null`) * [.NUMBER](#rtvref.types.NUMBER) : string * [.FINITE](#rtvref.types.FINITE) : string * [.INT](#rtvref.types.INT) : string - * [.INT](#rtvref.types.INT) : string + * [.SAFE_INT](#rtvref.types.SAFE_INT) : string * [.FLOAT](#rtvref.types.FLOAT) : string * [.FUNCTION](#rtvref.types.FUNCTION) : string * [.REGEXP](#rtvref.types.REGEXP) : string @@ -808,8 +1088,8 @@ Convenience function to check if a nil value (either `undefined` or `null`) * [.WEAK_SET](#rtvref.types.WEAK_SET) : string * [.JSON](#rtvref.types.JSON) : string * [.DEFAULT_OBJECT_TYPE](#rtvref.types.DEFAULT_OBJECT_TYPE) : string - * [.primitives](#rtvref.types.primitives) : \* - * [.rules](#rtvref.types.rules) : \* + * [.primitives](#rtvref.types.primitives) : void + * [.qualifier_rules](#rtvref.types.qualifier_rules) : void * [.shape_descriptor](#rtvref.types.shape_descriptor) : Object * [.type_arguments](#rtvref.types.type_arguments) : Object * [.STRING_args](#rtvref.types.STRING_args) : Object @@ -822,42 +1102,75 @@ Convenience function to check if a nil value (either `undefined` or `null`) * [.fully_qualified_typeset](#rtvref.types.fully_qualified_typeset) : Array * [.custom_validator](#rtvref.types.custom_validator) : function - -* * * - -#### types.objTypes : [Enumeration](#rtvref.Enumeration) -Enumeration (`string -> string`) of __object__ [types](#rtvref.types). These - are all the types that describe values which are essentially maps of various - keys to values. - -**Kind**: static property of [types](#rtvref.types) +### types.objTypes : [Enumeration](#rtvref.Enumeration) +Enumeration (`string -> string`) of __object__ types: -* * * +- [ANY_OBJECT](#rtvref.types.ANY_OBJECT) +- [OBJECT](#rtvref.types.OBJECT) +- [PLAIN_OBJECT](#rtvref.types.PLAIN_OBJECT) +- [CLASS_OBJECT](#rtvref.types.CLASS_OBJECT) +**Kind**: static property of [types](#rtvref.types) -#### types.argTypes : [Enumeration](#rtvref.Enumeration) -Enumeration (`string -> string`) of [types](#rtvref.types) that accept - arguments. - -**Kind**: static property of [types](#rtvref.types) +### types.argTypes : [Enumeration](#rtvref.Enumeration) +Enumeration (`string -> string`) of types that accept arguments: -* * * +- [STRING](#rtvref.types.STRING) +- [SYMBOL](#rtvref.types.SYMBOL) +- [NUMBER](#rtvref.types.NUMBER) +- [FINITE](#rtvref.types.FINITE) +- [INT](#rtvref.types.INT) +- [SAFE_INT](#rtvref.types.SAFE_INT) +- [FLOAT](#rtvref.types.FLOAT) +- [ARRAY](#rtvref.types.ARRAY) +- [ANY_OBJECT](#rtvref.types.ANY_OBJECT) +- [OBJECT](#rtvref.types.OBJECT) +- [PLAIN_OBJECT](#rtvref.types.PLAIN_OBJECT) +- [CLASS_OBJECT](#rtvref.types.CLASS_OBJECT) +- [HASH_MAP](#rtvref.types.HASH_MAP) +- [MAP](#rtvref.types.MAP) +- [SET](#rtvref.types.SET) +**Kind**: static property of [types](#rtvref.types) -#### types.types : [Enumeration](#rtvref.Enumeration) -Enumeration (`string -> string`) of all [types](#rtvref.types). +### types.types : [Enumeration](#rtvref.Enumeration) +Enumeration (`string -> string`) of all types: -**Kind**: static property of [types](#rtvref.types) - -* * * +- [ANY](#rtvref.types.ANY) +- [NULL](#rtvref.types.NULL) +- [STRING](#rtvref.types.STRING) +- [BOOLEAN](#rtvref.types.BOOLEAN) +- [SYMBOL](#rtvref.types.SYMBOL) +- [NUMBER](#rtvref.types.NUMBER) +- [FINITE](#rtvref.types.FINITE) +- [INT](#rtvref.types.INT) +- [SAFE_INT](#rtvref.types.SAFE_INT) +- [FLOAT](#rtvref.types.FLOAT) +- [FUNCTION](#rtvref.types.FUNCTION) +- [REGEXP](#rtvref.types.REGEXP) +- [DATE](#rtvref.types.DATE) +- [ERROR](#rtvref.types.ERROR) +- [PROMISE](#rtvref.types.PROMISE) +- [ARRAY](#rtvref.types.ARRAY) +- [ANY_OBJECT](#rtvref.types.ANY_OBJECT) +- [OBJECT](#rtvref.types.OBJECT) +- [PLAIN_OBJECT](#rtvref.types.PLAIN_OBJECT) +- [CLASS_OBJECT](#rtvref.types.CLASS_OBJECT) +- [HASH_MAP](#rtvref.types.HASH_MAP) +- [MAP](#rtvref.types.MAP) +- [WEAK_MAP](#rtvref.types.WEAK_MAP) +- [SET](#rtvref.types.SET) +- [WEAK_SET](#rtvref.types.WEAK_SET) +- [JSON](#rtvref.types.JSON) +**Kind**: static property of [types](#rtvref.types) -#### types.ANY : string +### types.ANY : string The any type is special in that it allows _anything_, which includes `null` and `undefined` values. Because of this, it's the most liberal in terms of types as well as qualifiers. A more specific type should be used whenever @@ -877,12 +1190,9 @@ Since this type removes the property's need for existence in the prototype **Kind**: static constant of [types](#rtvref.types) **See**: [qualifiers](#rtvref.qualifiers) - -* * * - -#### types.NULL : string +### types.NULL : string Null rules per qualifiers: must be the `null` [primitive](#rtvref.types.primitives). Use this special type to explicitly test for a `null` value. For example, @@ -891,12 +1201,9 @@ Use this special type to explicitly test for a `null` value. For example, **Kind**: static constant of [types](#rtvref.types) **See**: [qualifiers](#rtvref.qualifiers) - -* * * - -#### types.STRING : string +### types.STRING : string String rules per qualifiers: - REQUIRED: Must be a non-empty string. @@ -909,35 +1216,26 @@ Arguments (optional): [STRING_args](#rtvref.types.STRING_args) **Kind**: static constant of [types](#rtvref.types) **See**: [qualifiers](#rtvref.qualifiers) - -* * * - -#### types.BOOLEAN : string +### types.BOOLEAN : string Boolean rules per qualifiers: Must be a boolean [primitive](#rtvref.types.primitives). Note that `new Boolean(true) !== true` because the former is an _object_, not a boolean. **Kind**: static constant of [types](#rtvref.types) **See**: [qualifiers](#rtvref.qualifiers) - -* * * - -#### types.SYMBOL : string +### types.SYMBOL : string Symbol rules per qualifiers: Must be a symbol [primitive](#rtvref.types.primitives). Arguments (optional): [SYMBOL_args](#rtvref.types.SYMBOL_args). **Kind**: static constant of [types](#rtvref.types) **See**: [qualifiers](#rtvref.qualifiers) - -* * * - -#### types.NUMBER : string +### types.NUMBER : string Number rules per qualifiers: - REQUIRED: Cannot be `NaN`, but could be `+Infinity`, `-Infinity`. @@ -957,15 +1255,12 @@ Arguments (optional): [numeric_args](#rtvref.types.numeric_args) - [qualifiers](#rtvref.qualifiers) - [FINITE](#rtvref.types.FINITE) - [INT](#rtvref.types.INT) -- [rtvref.types.SAFE_INT](rtvref.types.SAFE_INT) +- [SAFE_INT](#rtvref.types.SAFE_INT) - [FLOAT](#rtvref.types.FLOAT) - -* * * - -#### types.FINITE : string +### types.FINITE : string Finite rules per qualifiers: Cannot be `NaN`, `+Infinity`, `-Infinity`. The value can be either an [integer](#rtvref.types.INT), or a [floating point number](#rtvref.types.FLOAT). It must also be a @@ -982,15 +1277,12 @@ Arguments (optional): [numeric_args](#rtvref.types.numeric_args) - [qualifiers](#rtvref.qualifiers) - [NUMBER](#rtvref.types.NUMBER) - [INT](#rtvref.types.INT) -- [rtvref.types.SAFE_INT](rtvref.types.SAFE_INT) +- [SAFE_INT](#rtvref.types.SAFE_INT) - [FLOAT](#rtvref.types.FLOAT) - -* * * - -#### types.INT : string +### types.INT : string Int rules per qualifiers: Must be a [finite](#rtvref.types.FINITE) number, an integer, and a number [primitive](#rtvref.types.primitives). @@ -1005,15 +1297,12 @@ Arguments (optional): [numeric_args](#rtvref.types.numeric_args) - [qualifiers](#rtvref.qualifiers) - [NUMBER](#rtvref.types.NUMBER) - [FINITE](#rtvref.types.FINITE) -- [rtvref.types.SAFE_INT](rtvref.types.SAFE_INT) +- [SAFE_INT](#rtvref.types.SAFE_INT) - [FLOAT](#rtvref.types.FLOAT) + -* * * - - - -#### types.INT : string +### types.SAFE_INT : string Int rules per qualifiers: Must be a [finite](#rtvref.types.FINITE) number, a [safe integer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger), and a number [primitive](#rtvref.types.primitives). @@ -1033,12 +1322,9 @@ Arguments (optional): [numeric_args](#rtvref.types.numeric_args) - [INT](#rtvref.types.INT) - [FLOAT](#rtvref.types.FLOAT) - -* * * - -#### types.FLOAT : string +### types.FLOAT : string Float rules per qualifiers: Must be a [finite](#rtvref.types.FINITE) floating point number, and a number [primitive](#rtvref.types.primitives). Per IEEE 754, zero is considered a float. @@ -1052,24 +1338,18 @@ Arguments (optional): [numeric_args](#rtvref.types.numeric_args) - [NUMBER](#rtvref.types.NUMBER) - [FINITE](#rtvref.types.FINITE) - [INT](#rtvref.types.INT) -- [rtvref.types.SAFE_INT](rtvref.types.SAFE_INT) - - -* * * +- [SAFE_INT](#rtvref.types.SAFE_INT) -#### types.FUNCTION : string +### types.FUNCTION : string Function rules per qualifiers: Must be a `function`. **Kind**: static constant of [types](#rtvref.types) **See**: [qualifiers](#rtvref.qualifiers) - -* * * - -#### types.REGEXP : string +### types.REGEXP : string RegExp rules per qualifiers: Must be a `RegExp` instance. **Kind**: static constant of [types](#rtvref.types) @@ -1078,12 +1358,9 @@ RegExp rules per qualifiers: Must be a `RegExp` instance. - [qualifiers](#rtvref.qualifiers) - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp - -* * * - -#### types.DATE : string +### types.DATE : string Date rules per qualifiers: Must be a `Date` instance. **Kind**: static constant of [types](#rtvref.types) @@ -1092,12 +1369,9 @@ Date rules per qualifiers: Must be a `Date` instance. - [qualifiers](#rtvref.qualifiers) - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date - -* * * - -#### types.ERROR : string +### types.ERROR : string Error rules per qualifiers: Must be an `Error` instance, which includes `TypeError`, `RangeError`, `ReferenceError`, etc. @@ -1107,12 +1381,9 @@ Error rules per qualifiers: Must be an `Error` instance, which includes `TypeErr - [qualifiers](#rtvref.qualifiers) - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error - -* * * - -#### types.PROMISE : string +### types.PROMISE : string Promise rules per qualifiers: Must be a `Promise` instance. **Kind**: static constant of [types](#rtvref.types) @@ -1121,12 +1392,9 @@ Promise rules per qualifiers: Must be a `Promise` instance. - [qualifiers](#rtvref.qualifiers) - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise - -* * * - -#### types.ARRAY : string +### types.ARRAY : string Array rules per qualifiers: Must be an `Array`. Empty arrays are permitted, unless arguments prevent them. @@ -1148,7 +1416,7 @@ __NOTE__: It's important to realize that arrays (as in the JavaScript Array They represent a set of types that will be used to validate each element of an array using a short-circuit OR conjunction, looking for the first type that matches. -

Example: Simple array

+

Array Example: Simple array

The `value` property must be an array (possibly empty) of any type of value. @@ -1163,7 +1431,7 @@ __NOTE__: Since arrays are, in reality, nested to indicate what could be the equivalent: `[[]]`. The inner Array typeset would be deemed _invalid_. -

Example: Shorthand notation

+

Array Example: Shorthand notation

The `value` property must be an array (possibly empty) of finite numbers of any value. @@ -1173,7 +1441,7 @@ The `value` property must be an array (possibly empty) of finite numbers of } -

Example: Shorthand, mixed types

+

Array Example: Shorthand, mixed types

The `value` property must be either a boolean; or an array (possibly empty) of finite numbers of any value, or non-empty strings, or a mix of both. @@ -1183,7 +1451,7 @@ The `value` property must be either a boolean; or an array (possibly empty) of } -

Example: Fully-qualified notation, no typeset

+

Array Example: Fully-qualified notation, no typeset

The `value` property must be a non-empty array of any type of value. @@ -1192,7 +1460,7 @@ The `value` property must be a non-empty array of any type of value. } -

Example: Fully-qualified notation

+

Array Example: Fully-qualified notation

The `value` property must be an array (possibly empty) of finite numbers of any value (nested typeset is not fully-qualified). @@ -1202,7 +1470,7 @@ The `value` property must be an array (possibly empty) of finite numbers of } -

Example: Fully-qualified, mixed types

+

Array Example: Fully-qualified, mixed types

The `value` property must be either a boolean; or an array (possibly empty) of finite numbers of any value, or non-empty strings, or a mix of both @@ -1215,12 +1483,9 @@ The `value` property must be either a boolean; or an array (possibly empty) of **Kind**: static constant of [types](#rtvref.types) **See**: [qualifiers](#rtvref.qualifiers) - -* * * - -#### types.ANY_OBJECT : string +### types.ANY_OBJECT : string An _any_ object is anything that is __not__ a [primitive](#rtvref.types), which means it includes the `Array` type, as well as functions and arguments, and other JavaScript _object_ types. To test for an array, use the @@ -1271,12 +1536,9 @@ Arguments (optional): [shape_object_args](#rtvref.types.shape_object_args) - [PLAIN_OBJECT](#rtvref.types.PLAIN_OBJECT) - [CLASS_OBJECT](#rtvref.types.CLASS_OBJECT) - -* * * - -#### types.OBJECT : string +### types.OBJECT : string An object is one that extends from `JavaScript.Object` (i.e. an _instance_ of _something_ that extends from Object) and is not a [function](#rtvref.types.FUNCTION), [array](#rtvref.types.ARRAY), @@ -1334,12 +1596,9 @@ Arguments (optional): [shape_object_args](#rtvref.types.shape_object_args) - [PLAIN_OBJECT](#rtvref.types.PLAIN_OBJECT) - [CLASS_OBJECT](#rtvref.types.CLASS_OBJECT) - -* * * - -#### types.PLAIN_OBJECT : string +### types.PLAIN_OBJECT : string A _plain_ object is one that is created directly from the `Object` constructor, whether using `new Object()` or the literal `{}`. @@ -1386,12 +1645,9 @@ Arguments (optional): [shape_object_args](#rtvref.types.shape_object_args) - [OBJECT](#rtvref.types.OBJECT) - [CLASS_OBJECT](#rtvref.types.CLASS_OBJECT) - -* * * - -#### types.CLASS_OBJECT : string +### types.CLASS_OBJECT : string A _class_ object is one that is created by invoking the `new` operator on a function (other than a primitive type function), generating a new object, commonly referred to as a _class instance_. This object's prototype @@ -1441,12 +1697,9 @@ Arguments (optional): [shape_object_args](#rtvref.types.shape_object_args) - [OBJECT](#rtvref.types.OBJECT) - [PLAIN_OBJECT](#rtvref.types.PLAIN_OBJECT) - -* * * - -#### types.HASH_MAP : string +### types.HASH_MAP : string A simple [OBJECT](#rtvref.types.OBJECT) that is treated as a hash map with an expected set of keys (forcibly strings due to the nature of the native JavaScript `Object` type) and values. Keys are __own-properties only__, @@ -1468,12 +1721,9 @@ Arguments (optional): [collection_args](#rtvref.types.collection_args) - [MAP](#rtvref.types.MAP) - [WEAK_MAP](#rtvref.types.WEAK_MAP) - -* * * - -#### types.MAP : string +### types.MAP : string An ES6 map supports any value as its keys, unlike a [HASH_MAP](#rtvref.types.HASH_MAP) that only supports strings. Keys can be described using a regular expression (if they are strings), and values can @@ -1491,12 +1741,9 @@ Arguments (optional): [collection_args](#rtvref.types.collection_args) - [HASH_MAP](#rtvref.types.HASH_MAP) - [WEAK_MAP](#rtvref.types.WEAK_MAP) - -* * * - -#### types.WEAK_MAP : string +### types.WEAK_MAP : string An ES6 weak map supports any _object_ as its keys, unlike a [HASH_MAP](#rtvref.types.HASH_MAP) that only supports strings, and a [MAP](#rtvref.types.MAP) that supports any type of value. @@ -1510,12 +1757,9 @@ Weak map rules per qualifiers: Must be a `WeakMap` instance. - [HASH_MAP](#rtvref.types.HASH_MAP) - [MAP](#rtvref.types.MAP) - -* * * - -#### types.SET : string +### types.SET : string An ES6 set is a collection of _unique_ values without associated keys. Values can be described using a [typeset](#rtvref.types.typeset). Empty sets are permitted by default. @@ -1530,12 +1774,9 @@ Arguments (optional): [collection_args](#rtvref.types.collection_args) - [qualifiers](#rtvref.qualifiers) - [WEAK_SET](#rtvref.types.WEAK_SET) - -* * * - -#### types.WEAK_SET : string +### types.WEAK_SET : string An ES6 weak set is a collection of weakly held _unique_ _objects_ without associated keys. @@ -1547,12 +1788,9 @@ Weak set rules per qualifiers: Must be a `WeakSet` instance. - [qualifiers](#rtvref.qualifiers) - [SET](#rtvref.types.SET) - -* * * - -#### types.JSON : string +### types.JSON : string JSON rules per qualifiers: Must be a JSON value: - [null](#rtvref.types.NULL) @@ -1570,21 +1808,15 @@ Since this type checks for _any_ valid JSON value, empty string and `null` **Kind**: static constant of [types](#rtvref.types) **See**: [qualifiers](#rtvref.qualifiers) - -* * * - -#### types.DEFAULT_OBJECT_TYPE : string +### types.DEFAULT_OBJECT_TYPE : string Default object type: [OBJECT](#rtvref.types.OBJECT) **Kind**: static constant of [types](#rtvref.types) - -* * * - -#### types.primitives : \* +### types.primitives : void

Primitives

In RTV.js (as in [ECMAScript 2015](https://developer.mozilla.org/en-US/docs/Glossary/Primitive)), @@ -1601,13 +1833,10 @@ In RTV.js (as in [ECMAScript 2015](https://developer.mozilla.org/en-US/docs/Glos - `Symbol` **Kind**: static typedef of [types](#rtvref.types) -**See**: [rtvref.validation.isPrimitive](rtvref.validation.isPrimitive) - -* * * +**See**: [isPrimitive](#rtvref.validation.isPrimitive) + - - -#### types.rules : \* +### types.qualifier_rules : void

Rules Per Qualifiers

[Qualifiers](#rtvref.qualifiers) state basic rules. Unless otherwise stated, @@ -1620,12 +1849,9 @@ For example, while the [FINITE](#rtvref.types.FINITE) type states that the used is `OPTIONAL`. **Kind**: static typedef of [types](#rtvref.types) - -* * * - -#### types.shape_descriptor : Object +### types.shape_descriptor : Object

Shape Descriptor

Describes the shape (i.e. interface) of an object as a map of properties to @@ -1646,13 +1872,10 @@ When a value is [checked](#rtv.check) or [verified](#rtv.verify) against The shape descriptor itself must be an [OBJECT](#rtvref.types.OBJECT). **Kind**: static typedef of [types](#rtvref.types) -**See**: [rtvref.validation.isShape](rtvref.validation.isShape) - -* * * - +**See**: [isShape](#rtvref.validation.isShape) -#### types.type_arguments : Object +### types.type_arguments : Object

Type Arguments

Some types will accept, or may even expect, one or more arguments. Each type @@ -1671,20 +1894,17 @@ An arguments object immediately follows its type in a typeset, such as of at least 5 characters in length. Since [qualifiers](#rtvref.qualifiers) may affect how a value is validated - against a type, [qualifier rules](#rtvref.types.rules) always take + against a type, [qualifier rules](#rtvref.types.qualifier_rules) always take __precedence__ over any argument specified. For example, `[STRING, {min: 0}]` would fail to validate an empty string because the _implied_ qualifier is `REQUIRED`, and per [STRING](#rtvref.types.STRING) qualifier rules, required strings cannot be empty. **Kind**: static typedef of [types](#rtvref.types) -**See**: [rtvref.validation.isTypeArgs](rtvref.validation.isTypeArgs) - -* * * - +**See**: [isTypeArgs](#rtvref.validation.isTypeArgs) -#### types.STRING_args : Object +### types.STRING_args : Object

String Arguments

**Kind**: static typedef of [types](#rtvref.types) @@ -1698,12 +1918,9 @@ Since [qualifiers](#rtvref.qualifiers) may affect how a value is validated | [min] | number | Minimum inclusive length. Defaults to 1 for a `REQUIRED` string, and 0 for an `EXPECTED` or `OPTIONAL` string. Ignored if `exact` is specified, or `min` is not a [FINITE](#rtvref.types.FINITE) number >= 0. | | [max] | number | Maximum inclusive length. Negative means no maximum. Ignored if `exact` is specified, `max` is not a [FINITE](#rtvref.types.FINITE) number, or `max` is less than `min`. | - -* * * - -#### types.SYMBOL_args : Object +### types.SYMBOL_args : Object

Symbol Arguments

**Kind**: static typedef of [types](#rtvref.types) @@ -1714,12 +1931,9 @@ Since [qualifiers](#rtvref.qualifiers) may affect how a value is validated | --- | --- | --- | | [oneOf] | symbol \| Array.<symbol> | An exact symbol to match (`===`). Can also be a list of symbols, one of which must be an exact match. Values to match are ignored if they are not symbols. An empty list will be ignored. | - -* * * - -#### types.numeric_args : Object +### types.numeric_args : Object

Numeric Value Arguments

Applicable to all numeric types: @@ -1727,7 +1941,7 @@ Applicable to all numeric types: - [NUMBER](#rtvref.types.NUMBER) - [FINITE](#rtvref.types.FINITE) - [INT](#rtvref.types.INT) -- [SAFE_INT](rtvref.types.SAFE_INT) +- [SAFE_INT](#rtvref.types.SAFE_INT) - [FLOAT](#rtvref.types.FLOAT) **Kind**: static typedef of [types](#rtvref.types) @@ -1736,7 +1950,7 @@ Applicable to all numeric types: - [NUMBER](#rtvref.types.NUMBER) - [FINITE](#rtvref.types.FINITE) - [INT](#rtvref.types.INT) -- [rtvref.types.SAFE_INT](rtvref.types.SAFE_INT) +- [SAFE_INT](#rtvref.types.SAFE_INT) - [FLOAT](#rtvref.types.FLOAT) - [qualifiers](#rtvref.qualifiers) @@ -1748,12 +1962,9 @@ Applicable to all numeric types: | [min] | number | Minimum inclusive value. Ignored if `exact` is specified, `min` is `NaN`, or `min` is not within normal range of the type. | | [max] | number | Maximum inclusive value. Ignored if `exact` is specified, `max` is `NaN`, `max` is not within normal range of the type, or `max` is less than `min`. | - -* * * - -#### types.shape_object_args : Object +### types.shape_object_args : Object

Shape Object Arguments

Applicable to all object types that may have a shape: @@ -1778,12 +1989,9 @@ Applicable to all object types that may have a shape: | [$] | Object | The [shape descriptor](#rtvref.types.shape_descriptor) describing the expected interface of the value being verified. If not specified, none of the value's properties will be verified. Applies to all shape object types. | | [ctor] | function | A reference to a constructor function. If specified, the class object (instance) must have this class function in its inheritance chain such that ` instanceof ctor === true`. Note that this property is not serializable to JSON. Ignored if not a [function](#rtvref.types.FUNCTION). Applies to: [CLASS_OBJECT](#rtvref.types.CLASS_OBJECT). | - -* * * - -#### types.ARRAY_args : Object +### types.ARRAY_args : Object

Array Arguments

**Kind**: static typedef of [types](#rtvref.types) @@ -1797,12 +2005,9 @@ Applicable to all object types that may have a shape: | [min] | number | Minimum inclusive length. Ignored if `exact` is specified, or `min` is not a [FINITE](#rtvref.types.FINITE) number >= 0. | | [max] | number | Maximum inclusive length. Negative means no maximum. Ignored if `exact` is specified, `max` is not a [FINITE](#rtvref.types.FINITE) number, or `max` is less than `min`. | - -* * * - -#### types.collection_args : Object +### types.collection_args : Object

Collection Arguments

Describes the keys and values in a collection-based object, which is one of @@ -1844,12 +2049,9 @@ The [WEAK_MAP](#rtvref.types.WEAK_MAP) and [WEAK_SET](#rtvref.types.WEAK_SET) | [keyFlagSpec] | string | A string specifying any flags to use with the regular expression specified in `keyExp`. Ignored if _falsy_ or if `keyExp` is not specified. See the [RegExp#flags](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) parameter for more information. Applies to: [HASH_MAP](#rtvref.types.HASH_MAP), [MAP](#rtvref.types.MAP). | | [values] | [typeset](#rtvref.types.typeset) | A typeset describing each value in the collection. If specified, all values must match this typeset (but the collection is not required to have any elements to be considered valid, unless `length` is specified). If not specified, no validation is performed on values. For example, to require arrays of non-empty string values as values in the collection, the following typeset could be used: `[[types.STRING]]`. Applies to: All collection types. | - -* * * - -#### types.typeset : Object \| string \| Array \| function +### types.typeset : Object \| string \| Array \| function

Typeset

Describes the possible types for a given value. It can be any one of the following @@ -1941,7 +2143,7 @@ This could, among other possibilities, enable the transmission of typesets over network requests, perhaps embedded in JSON payloads, similar to [JSON-LD](https://json-ld.org/) schemas. -

Example: Object

+

Typeset Example: Object

const contactShape = {
   name: rtv.t.STRING, // required, non-empty, string
@@ -1984,20 +2186,20 @@ rtv.verify({
 }, walletShape); // OK
 
-

Example: String

+

Typeset Example: String

rtv.verify('foo', rtv.t.STRING); // OK
 rtv.verify('foo', rtv.t.FINITE); // ERROR
 
-

Example: Array

+

Typeset Example: Array

const typeset = [rtv.t.STRING, rtv.t.FINITE]; // non-empty string, or finite number
 rtv.verify('foo', typeset); // OK
 rtv.verify(1, typeset); // OK
 
-

Example: Function

+

Typeset Example: Function

const validator = (v) => {
   if (v % 10) {
@@ -2009,7 +2211,7 @@ rtv.verify(100, validator); // OK
 rtv.verify(120, [rtv.t.INT, validator]); // OK
 
-

Example: Alternate Qualifier

+

Typeset Example: Alternate Qualifier

const person = {
   name: rtv.t.STRING, // required, non-empty
@@ -2026,12 +2228,9 @@ rtv.verify({name: 'Steve', age: null}, person); // OK
 
**Kind**: static typedef of [types](#rtvref.types) - -* * * - -#### types.fully_qualified_typeset : Array +### types.fully_qualified_typeset : Array

Fully-Qualified Typeset

A [typeset](#rtvref.types.typeset) expressed without any shortcut notations @@ -2049,12 +2248,9 @@ For example: - `(v) => if (!v) { throw new Error(); }` -> `[REQUIRED, ANY, (v) => if (!v) { throw new Error(); }]` **Kind**: static typedef of [types](#rtvref.types) - -* * * - -#### types.custom_validator : function +### types.custom_validator : function

Custom Validator

A function used as a [typeset](#rtvref.types.typeset), or as a subset to @@ -2087,7 +2283,7 @@ There is one disadvantage to using a custom validator: It cannot be de/serialize `message`. Therefore, it's recommended to throw an error with a message that will help the developer determine why the custom validation failed. -**See**: [rtvref.validation.isValidator](rtvref.validation.isValidator) +**See**: [isCustomValidator](#rtvref.validation.isCustomValidator) | Param | Type | Description | | --- | --- | --- | @@ -2095,13 +2291,29 @@ There is one disadvantage to using a custom validator: It cannot be de/serialize | match | Array | A __first-level__, [fully-qualified](#rtvref.types.fully_qualified_typeset) typeset describing the type that matched. This means the first level of this subset of `typeset` (the 3rd parameter) is fully-qualified, but any nested [shape descriptors](#rtvref.types.shape_descriptor) or arrays will not be (they will remain references to the same shapes/arrays in `typeset`). For example, if the given typeset was `[PLAIN_OBJECT, {$: {note: STRING}}]`, this parameter would be a new typeset array `[REQUIRED, PLAIN_OBJECT, {$: {note: STRING}}]`, and the `typeset` parameter would be the original `[PLAIN_OBJECT, {$: {note: STRING}}]`. If the given typeset was `[STRING, FINITE]` and FINITE matched, this parameter would be `[REQUIRED, FINITE]` and the `typeset` parameter would be the original `[STRING, FINITE]`. | | typeset | [typeset](#rtvref.types.typeset) | Reference to the typeset used for verification. Note that the typeset may contain nested typeset(s), and may be part of a larger parent typeset (though there would be no reference to the parent typeset, if any). This typeset is as it was specified in the parent shape, and therefore it may not be fully-qualified. | + + +## rtvref.util : object +

RTV.js Utilities

+ +**Kind**: static namespace of [rtvref](#rtvref) + + +### util.print(printValue) ⇒ string +Pretty-print a value. + +**Kind**: static method of [util](#rtvref.util) +**Returns**: string - Pretty-printed value. It's not perfect and may not catch + all types, but attempts to be good enough. -* * * +| Param | Type | Description | +| --- | --- | --- | +| printValue | \* | Value to print. | -### rtvref.validation : object -

RTV Validation

+## rtvref.validation : object +

RTV.js Validation

This namespace provides _type validations_ which verify values to be of the [types](#rtvref.types) defined in this library. If permitted values @@ -2111,7 +2323,7 @@ This namespace provides _type validations_ which verify values to be of qualifiers like [type validators](#rtvref.validator) do. Validations may also check for pseudo-types, such as the - [isTypeset](rtvref.validation.isTypeset) validation verifying a value as + [isTypeset](#rtvref.validation.isTypeset) validation verifying a value as a [typeset](#rtvref.types.typeset), which is not an actual type. __Every validation module must provide the following interface:__ @@ -2135,11 +2347,105 @@ NOTE: Where possible, validations should use the other validations rather than **Kind**: static namespace of [rtvref](#rtvref) -* * * +* [.validation](#rtvref.validation) : object + * [.method(value)](#rtvref.validation.method) ⇒ boolean + * [.isAny](#rtvref.validation.isAny) : Module + * [.type](#rtvref.validation.isAny.type) : string + * [.default(v)](#rtvref.validation.isAny.default) ⇒ boolean + * [.isAnyObject](#rtvref.validation.isAnyObject) : Module + * [.type](#rtvref.validation.isAnyObject.type) : string + * [.default(v)](#rtvref.validation.isAnyObject.default) ⇒ boolean + * [.isArray](#rtvref.validation.isArray) : Module + * [.type](#rtvref.validation.isArray.type) : string + * [.default(v)](#rtvref.validation.isArray.default) ⇒ boolean + * [.isBoolean](#rtvref.validation.isBoolean) : Module + * [.type](#rtvref.validation.isBoolean.type) : string + * [.default(v)](#rtvref.validation.isBoolean.default) ⇒ boolean + * [.isClassObject](#rtvref.validation.isClassObject) : Module + * [.type](#rtvref.validation.isClassObject.type) : string + * [.default(v)](#rtvref.validation.isClassObject.default) ⇒ boolean + * [.isCustomValidator](#rtvref.validation.isCustomValidator) : Module + * [.type](#rtvref.validation.isCustomValidator.type) : string + * [.default(v)](#rtvref.validation.isCustomValidator.default) ⇒ boolean + * [.isDate](#rtvref.validation.isDate) : Module + * [.type](#rtvref.validation.isDate.type) : string + * [.default(v)](#rtvref.validation.isDate.default) ⇒ boolean + * [.isError](#rtvref.validation.isError) : Module + * [.type](#rtvref.validation.isError.type) : string + * [.default(v)](#rtvref.validation.isError.default) ⇒ boolean + * [.isFinite](#rtvref.validation.isFinite) : Module + * [.type](#rtvref.validation.isFinite.type) : string + * [.default(v)](#rtvref.validation.isFinite.default) ⇒ boolean + * [.isFloat](#rtvref.validation.isFloat) : Module + * [.type](#rtvref.validation.isFloat.type) : string + * [.default(v)](#rtvref.validation.isFloat.default) ⇒ boolean + * [.isFunction](#rtvref.validation.isFunction) : Module + * [.type](#rtvref.validation.isFunction.type) : string + * [.default(v)](#rtvref.validation.isFunction.default) ⇒ boolean + * [.isHashMap](#rtvref.validation.isHashMap) : Module + * [.type](#rtvref.validation.isHashMap.type) : string + * [.default(v)](#rtvref.validation.isHashMap.default) ⇒ boolean + * [.isInt](#rtvref.validation.isInt) : Module + * [.type](#rtvref.validation.isInt.type) : string + * [.default(v)](#rtvref.validation.isInt.default) ⇒ boolean + * [.isJson](#rtvref.validation.isJson) : Module + * [.type](#rtvref.validation.isJson.type) : string + * [.default(v)](#rtvref.validation.isJson.default) ⇒ boolean + * [.isMap](#rtvref.validation.isMap) : Module + * [.type](#rtvref.validation.isMap.type) : string + * [.default(v)](#rtvref.validation.isMap.default) ⇒ boolean + * [.isNull](#rtvref.validation.isNull) : Module + * [.type](#rtvref.validation.isNull.type) : string + * [.default(v)](#rtvref.validation.isNull.default) ⇒ boolean + * [.isNumber](#rtvref.validation.isNumber) : Module + * [.type](#rtvref.validation.isNumber.type) : string + * [.default(v)](#rtvref.validation.isNumber.default) ⇒ boolean + * [.isObject](#rtvref.validation.isObject) : Module + * [.type](#rtvref.validation.isObject.type) : string + * [.default(v)](#rtvref.validation.isObject.default) ⇒ boolean + * [.isPlainObject](#rtvref.validation.isPlainObject) : Module + * [.type](#rtvref.validation.isPlainObject.type) : string + * [.default(v)](#rtvref.validation.isPlainObject.default) ⇒ boolean + * [.isPrimitive](#rtvref.validation.isPrimitive) : Module + * [.type](#rtvref.validation.isPrimitive.type) : string + * [.default(v)](#rtvref.validation.isPrimitive.default) ⇒ boolean + * [.isPromise](#rtvref.validation.isPromise) : Module + * [.type](#rtvref.validation.isPromise.type) : string + * [.default(v)](#rtvref.validation.isPromise.default) ⇒ boolean + * [.isRegExp](#rtvref.validation.isRegExp) : Module + * [.type](#rtvref.validation.isRegExp.type) : string + * [.default(v)](#rtvref.validation.isRegExp.default) ⇒ boolean + * [.isSafeInt](#rtvref.validation.isSafeInt) : Module + * [.type](#rtvref.validation.isSafeInt.type) : string + * [.default(v)](#rtvref.validation.isSafeInt.default) ⇒ boolean + * [.isSet](#rtvref.validation.isSet) : Module + * [.type](#rtvref.validation.isSet.type) : string + * [.default(v)](#rtvref.validation.isSet.default) ⇒ boolean + * [.isShape](#rtvref.validation.isShape) : Module + * [.type](#rtvref.validation.isShape.type) : string + * [.default(v)](#rtvref.validation.isShape.default) ⇒ boolean + * [.isString](#rtvref.validation.isString) : Module + * [.type](#rtvref.validation.isString.type) : string + * [.default(v, [options])](#rtvref.validation.isString.default) ⇒ boolean + * [.isSymbol](#rtvref.validation.isSymbol) : Module + * [.type](#rtvref.validation.isSymbol.type) : string + * [.default(v)](#rtvref.validation.isSymbol.default) ⇒ boolean + * [.isTypeArgs](#rtvref.validation.isTypeArgs) : Module + * [.type](#rtvref.validation.isTypeArgs.type) : string + * [.default(v)](#rtvref.validation.isTypeArgs.default) ⇒ boolean + * [.isTypeset](#rtvref.validation.isTypeset) : Module + * [.type](#rtvref.validation.isTypeset.type) : string + * [.default(v, [options])](#rtvref.validation.isTypeset.default) ⇒ boolean + * [.isWeakMap](#rtvref.validation.isWeakMap) : Module + * [.type](#rtvref.validation.isWeakMap.type) : string + * [.default(v)](#rtvref.validation.isWeakMap.default) ⇒ boolean + * [.isWeakSet](#rtvref.validation.isWeakSet) : Module + * [.type](#rtvref.validation.isWeakSet.type) : string + * [.default(v)](#rtvref.validation.isWeakSet.default) ⇒ boolean -#### validation.method(value) ⇒ boolean +### validation.method(value) ⇒ boolean

Type Validation Method

Verifies a value is of a certain [type](#rtvref.types). @@ -2151,328 +2457,2324 @@ Verifies a value is of a certain [type](#rtvref.types). | --- | --- | --- | | value | \* | The value to validate. | + -* * * +### validation.isAny : Module +Validation Module: isAny - +**Kind**: static typedef of [validation](#rtvref.validation) -### rtvref.validator : object -

RTV Type Validators

+* [.isAny](#rtvref.validation.isAny) : Module + * [.type](#rtvref.validation.isAny.type) : string + * [.default(v)](#rtvref.validation.isAny.default) ⇒ boolean -This namespace provides validators for each supported [type](#rtvref.types), - capable of fully validating a value against that type. Validators differ from - type _validations_ provided by the [validation](#rtvref.validation) - module in that validators verify a value against a single, specific type, - considering [qualifiers](#rtvref.qualifiers) as well as - [type arguments](#rtvref.types.type_arguments). + -__Every validator module must provide the following interface:__ +#### isAny.type : string +Type: [ANY](#rtvref.types.ANY) -- `{function} default` (the default export): The - [type validator](#rtvref.validator.type_validator) itself. -- `{string} type`: The [type](#rtvref.types) verified. -- `{function} config`: The - [configuration function](#rtvref.validator.validator_config). +**Kind**: static constant of [isAny](#rtvref.validation.isAny) + -Validator modules should be named as `val` such that their default - export is named `val`. +#### isAny.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [ANY](#rtvref.types.ANY) type. -There can only be one validator for any given type. Where possible, each - validator should use applicable [type validations](#rtvref.validation) - rather than third-party code (e.g. lodash) to ensure that the semantics of - each type is properly interpreted. If the validator introduces an entirely - new type, then it should use whatever means necessary to properly identify - the type which it validates. +**Kind**: static method of [isAny](#rtvref.validation.isAny) +**Returns**: boolean - `true` if validated; `false` otherwise. -**Kind**: static namespace of [rtvref](#rtvref) +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | -* [.validator](#rtvref.validator) : object - * [.type_validator(value, [qualifier], [args])](#rtvref.validator.type_validator) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - * [.validator_config(settings)](#rtvref.validator.validator_config) - * [.validator_config_settings](#rtvref.validator.validator_config_settings) : Object + +### validation.isAnyObject : Module +Validation Module: isAnyObject -* * * +**Kind**: static typedef of [validation](#rtvref.validation) - +* [.isAnyObject](#rtvref.validation.isAnyObject) : Module + * [.type](#rtvref.validation.isAnyObject.type) : string + * [.default(v)](#rtvref.validation.isAnyObject.default) ⇒ boolean -#### validator.type_validator(value, [qualifier], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) -

Type Validator Function

+ -NOTE: A validator must always give __precedence__ to - [qualifier rules](#rtvref.types.rules) for the type it's validating, over - any arguments specified. For example, +#### isAnyObject.type : string +Type: [ANY_OBJECT](#rtvref.types.ANY_OBJECT) -__NOTE:__ A validator must support all its qualifier rules, including proper - handling of `null` values when [EXPECTED](#rtvref.qualifiers.EXPECTED) - and `undefined` values when [OPTIONAL](#rtvref.qualifiers.OPTIONAL), - __in addition to__ and type-specific qualifier rules. For example, the - [STRING](#rtvref.types.STRING) type permits empty strings when not - [REQUIRED](#rtvref.qualifiers.REQUIRED). +**Kind**: static constant of [isAnyObject](#rtvref.validation.isAnyObject) + -**Kind**: static method of [validator](#rtvref.validator) -**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; - `RtvError` if not. +#### isAnyObject.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [ANY_OBJECT](#rtvref.types.ANY_OBJECT) type. + +**Kind**: static method of [isAnyObject](#rtvref.validation.isAnyObject) +**Returns**: boolean - `true` if validated; `false` otherwise. | Param | Type | Description | | --- | --- | --- | -| value | \* | The value to validate. | -| [qualifier] | string | The validation qualifier from the immediate [typeset](#rtvref.types.typeset) in which the pertaining type was specified. Validators should always explicitly default to [REQUIRED](#rtvref.qualifiers.REQUIRED) to maintain consistent behavior. | -| [args] | Object | The arguments object, if any/applicable, for the type being validated. For example, [string args](#rtvref.types.STRING_args) in a typeset such as `[rtv.t.STRING, {min: 5}]` (a required string of at least 5 characters in length). | +| v | \* | Value to validate. | + -* * * - - - -#### validator.validator_config(settings) -

Type Validator Configuration Function

+### validation.isArray : Module +Validation Module: isArray -This function is called to provide the - [type validator](#rtvref.validator.type_validator) with access to - internal utilities. +**Kind**: static typedef of [validation](#rtvref.validation) -**Kind**: static method of [validator](#rtvref.validator) +* [.isArray](#rtvref.validation.isArray) : Module + * [.type](#rtvref.validation.isArray.type) : string + * [.default(v)](#rtvref.validation.isArray.default) ⇒ boolean -| Param | Type | Description | -| --- | --- | --- | -| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + +#### isArray.type : string +Type: [ARRAY](#rtvref.types.ARRAY) -* * * +**Kind**: static constant of [isArray](#rtvref.validation.isArray) + - +#### isArray.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [ARRAY](#rtvref.types.ARRAY) type. -#### validator.validator_config_settings : Object -

Type Validator Configuration Settings

+**Kind**: static method of [isArray](#rtvref.validation.isArray) +**Returns**: boolean - `true` if validated; `false` otherwise. -The settings provided to the - [configuration function](#rtvref.validator.validator_config). +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | -**Kind**: static typedef of [validator](#rtvref.validator) -**Properties** + -| Name | Type | Description | -| --- | --- | --- | -| impl | [impl](#rtvref.impl) | Reference to the `impl` module. | +### validation.isBoolean : Module +Validation Module: isBoolean +**Kind**: static typedef of [validation](#rtvref.validation) -* * * +* [.isBoolean](#rtvref.validation.isBoolean) : Module + * [.type](#rtvref.validation.isBoolean.type) : string + * [.default(v)](#rtvref.validation.isBoolean.default) ⇒ boolean - + -## rtv : object -

RTV.js

+#### isBoolean.type : string +Type: [BOOLEAN](#rtvref.types.BOOLEAN) -Runtime Verification Library for browsers and Node.js. +**Kind**: static constant of [isBoolean](#rtvref.validation.isBoolean) + -**Kind**: global namespace +#### isBoolean.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [BOOLEAN](#rtvref.types.BOOLEAN) type. -* [rtv](#rtv) : object - * [.t](#rtv.t) : rtvref.Enumeration.<String, String> - * [.q](#rtv.q) : rtvref.Enumeration.<String, String> - * [.e](#rtv.e) : boolean - * [.config](#rtv.config) : object - * [.enabled](#rtv.config.enabled) : boolean - * [.isTypeset()](#rtv.isTypeset) - * [.check(value, typeset)](#rtv.check) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - * [.c(value, typeset)](#rtv.c) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - * [.verify(value, typeset)](#rtv.verify) ⇒ [RtvSuccess](#rtvref.RtvSuccess) - * [.v(value, typeset)](#rtv.v) ⇒ [RtvSuccess](#rtvref.RtvSuccess) +Determines if a value is a boolean literal __only__ (i.e. a + [primitive](#rtvref.types.primitives)). It does not validate + `new Boolean(true)`, which is an object that is a boolean. +**Kind**: static method of [isBoolean](#rtvref.validation.isBoolean) +**Returns**: boolean - `true` if validated; `false` otherwise. -* * * +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | - + -### rtv.t : rtvref.Enumeration.<String, String> -Enumeration of [types](#rtvref.types). +### validation.isClassObject : Module +Validation Module: isClassObject -**Kind**: static property of [rtv](#rtv) +**Kind**: static typedef of [validation](#rtvref.validation) -* * * +* [.isClassObject](#rtvref.validation.isClassObject) : Module + * [.type](#rtvref.validation.isClassObject.type) : string + * [.default(v)](#rtvref.validation.isClassObject.default) ⇒ boolean - + -### rtv.q : rtvref.Enumeration.<String, String> -Enumeration of [qualifiers](#rtvref.qualifiers). +#### isClassObject.type : string +Type: [CLASS_OBJECT](#rtvref.types.CLASS_OBJECT) -**Kind**: static property of [rtv](#rtv) +**Kind**: static constant of [isClassObject](#rtvref.validation.isClassObject) + -* * * +#### isClassObject.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [CLASS_OBJECT](#rtvref.types.CLASS_OBJECT) type. - +**Kind**: static method of [isClassObject](#rtvref.validation.isClassObject) +**Returns**: boolean - `true` if validated; `false` otherwise. -### rtv.e : boolean -Shortcut proxy for reading [enabled](#rtv.config.enabled). +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | -**Kind**: static property of [rtv](#rtv) -**Read only**: true + -* * * +### validation.isCustomValidator : Module +Validation Module: isCustomValidator - +**Kind**: static typedef of [validation](#rtvref.validation) -### rtv.config : object -RTV Library Configuration +* [.isCustomValidator](#rtvref.validation.isCustomValidator) : Module + * [.type](#rtvref.validation.isCustomValidator.type) : string + * [.default(v)](#rtvref.validation.isCustomValidator.default) ⇒ boolean -**Kind**: static namespace of [rtv](#rtv) + -* * * +#### isCustomValidator.type : string +Type: `undefined`, [custom validator](#rtvref.types.custom_validator) pseudo-type. - +**Kind**: static constant of [isCustomValidator](#rtvref.validation.isCustomValidator) + -#### config.enabled : boolean -Globally enables or disables [verify](#rtv.verify) and [check](#rtv.check). +#### isCustomValidator.default(v) ⇒ boolean +Determines if a value is a [custom validator](#rtvref.types.custom_validator). -Use this, or the shortcut [e](#rtv.e), 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/). +**Kind**: static method of [isCustomValidator](#rtvref.validation.isCustomValidator) +**Returns**: boolean - `true` if it is; `false` otherwise. -

Example

+| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | -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. + -// TODO: Add Rollup and Webpack examples. +### validation.isDate : Module +Validation Module: isDate -
if (rtv.config.enabled) {
- rtv.verify(jsonResult, expectedShape);
-}
+**Kind**: static typedef of [validation](#rtvref.validation)  
 
-rtv.e && rtv.v(jsonResult, expectedShape); // even shorter
-
+* [.isDate](#rtvref.validation.isDate) : Module + * [.type](#rtvref.validation.isDate.type) : string + * [.default(v)](#rtvref.validation.isDate.default) ⇒ boolean -**Kind**: static property of [config](#rtv.config) -**See**: [rtv.enabled](rtv.enabled) + -* * * +#### isDate.type : string +Type: [DATE](#rtvref.types.DATE) - +**Kind**: static constant of [isDate](#rtvref.validation.isDate) + -### rtv.isTypeset() -Determines if a value is a typeset. +#### isDate.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [DATE](#rtvref.types.DATE) type. -**Kind**: static method of [rtv](#rtv) -**See**: [default](#rtvref.validation.isTypeset.default) +**Kind**: static method of [isDate](#rtvref.validation.isDate) +**Returns**: boolean - `true` if validated; `false` otherwise. -* * * +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | - + -### rtv.check(value, typeset) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) -Checks a value against a typeset for compliance. +### validation.isError : Module +Validation Module: isError -**Kind**: static method of [rtv](#rtv) -**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#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. +**Kind**: static typedef of [validation](#rtvref.validation) - 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 - easy to test for success/failure like this: - `if (rtv.check(2, rtv.t.FINITE).valid) {...}`. +* [.isError](#rtvref.validation.isError) : Module + * [.type](#rtvref.validation.isError.type) : string + * [.default(v)](#rtvref.validation.isError.default) ⇒ boolean - __NOTE:__ This method always returns a success indicator if RTV.js is currently - [disabled](#rtv.config.enabled). -**Throws**: + -- Error If `typeset` is not a valid typeset. +#### isError.type : string +Type: [ERROR](#rtvref.types.ERROR) -**See** +**Kind**: static constant of [isError](#rtvref.validation.isError) + -- [verify](#rtv.verify) -- [enabled](#rtv.config.enabled) -- [types](#rtvref.types) -- [shape_descriptor](#rtvref.types.shape_descriptor) +#### isError.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [ERROR](#rtvref.types.ERROR) type. +**Kind**: static method of [isError](#rtvref.validation.isError) +**Returns**: boolean - `true` if validated; `false` otherwise. | Param | Type | Description | | --- | --- | --- | -| value | \* | Value to check. | -| typeset | [typeset](#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). | +| v | \* | Value to validate. | + -* * * +### validation.isFinite : Module +Validation Module: isFinite - +**Kind**: static typedef of [validation](#rtvref.validation) -### rtv.c(value, typeset) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) -Shortcut proxy to [check](#rtv.check). +* [.isFinite](#rtvref.validation.isFinite) : Module + * [.type](#rtvref.validation.isFinite.type) : string + * [.default(v)](#rtvref.validation.isFinite.default) ⇒ boolean -**Kind**: static method of [rtv](#rtv) -**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#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. -**Throws**: + -- Error If `typeset` is not a valid typeset. +#### isFinite.type : string +Type: [FINITE](#rtvref.types.FINITE) + +**Kind**: static constant of [isFinite](#rtvref.validation.isFinite) + + +#### isFinite.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [FINITE](#rtvref.types.FINITE) type. + +Determines if a value is a finite number literal __only__ (i.e. a + [primitive](#rtvref.types.primitives)). It does not validate + `new Number(1)`, which is an object that is a number. -**See**: [check](#rtv.check) +**Kind**: static method of [isFinite](#rtvref.validation.isFinite) +**Returns**: boolean - `true` if validated; `false` otherwise. | Param | Type | Description | | --- | --- | --- | -| value | \* | Value to check. | -| typeset | [typeset](#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). | +| v | \* | Value to validate. | + -* * * +### validation.isFloat : Module +Validation Module: isFloat - +**Kind**: static typedef of [validation](#rtvref.validation) -### rtv.verify(value, typeset) ⇒ [RtvSuccess](#rtvref.RtvSuccess) -__Requires__ a value to be compliant to a shape. +* [.isFloat](#rtvref.validation.isFloat) : Module + * [.type](#rtvref.validation.isFloat.type) : string + * [.default(v)](#rtvref.validation.isFloat.default) ⇒ boolean -NOTE: This method does nothing if RTV.js is currently - [disabled](#rtv.config.enabled). + -**Kind**: static method of [rtv](#rtv) -**Returns**: [RtvSuccess](#rtvref.RtvSuccess) - Success indicator IIF the `value` is compliant - to the `shape`. Otherwise, an [RtvError](#rtvref.RtvError) __is thrown__. -**Throws**: +#### isFloat.type : string +Type: [FLOAT](#rtvref.types.FLOAT) -- RtvError If the `value` is not compliant to the `shape`. -- Error If `typeset` is not a valid typeset. +**Kind**: static constant of [isFloat](#rtvref.validation.isFloat) + -**See** +#### isFloat.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [FLOAT](#rtvref.types.FLOAT) type. -- [check](#rtv.check) -- [enabled](#rtv.config.enabled) -- [types](#rtvref.types) -- [shape_descriptor](#rtvref.types.shape_descriptor) +Determines if a value is a floating point literal __only__ (i.e. a + [primitive](#rtvref.types.primitives)). It does not validate + `new Number(1.5)`, which is an object that is a number. +**Kind**: static method of [isFloat](#rtvref.validation.isFloat) +**Returns**: boolean - `true` if validated; `false` otherwise. | Param | Type | Description | | --- | --- | --- | -| value | \* | Value to check. | -| typeset | [typeset](#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). | +| v | \* | Value to validate. | + -* * * +### validation.isFunction : Module +Validation Module: isFunction - +**Kind**: static typedef of [validation](#rtvref.validation) -### rtv.v(value, typeset) ⇒ [RtvSuccess](#rtvref.RtvSuccess) -Shortcut proxy to [verify](#rtv.verify). +* [.isFunction](#rtvref.validation.isFunction) : Module + * [.type](#rtvref.validation.isFunction.type) : string + * [.default(v)](#rtvref.validation.isFunction.default) ⇒ boolean -**Kind**: static method of [rtv](#rtv) -**Returns**: [RtvSuccess](#rtvref.RtvSuccess) - Success indicator IIF the `value` is compliant - to the `shape`. Otherwise, an [RtvError](#rtvref.RtvError) __is thrown__. -**Throws**: + -- RtvError If the `value` is not compliant to the `shape`. +#### isFunction.type : string +Type: [FUNCTION](#rtvref.types.FUNCTION) -**See**: [verify](#rtv.verify) +**Kind**: static constant of [isFunction](#rtvref.validation.isFunction) + + +#### isFunction.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [FUNCTION](#rtvref.types.FUNCTION) type. + +**Kind**: static method of [isFunction](#rtvref.validation.isFunction) +**Returns**: boolean - `true` if validated; `false` otherwise. | Param | Type | Description | | --- | --- | --- | -| value | \* | Value to check. | -| typeset | [typeset](#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). | +| v | \* | Value to validate. | + + + +### validation.isHashMap : Module +Validation Module: isHashMap + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isHashMap](#rtvref.validation.isHashMap) : Module + * [.type](#rtvref.validation.isHashMap.type) : string + * [.default(v)](#rtvref.validation.isHashMap.default) ⇒ boolean + + + +#### isHashMap.type : string +Type: [HASH_MAP](#rtvref.types.HASH_MAP) + +**Kind**: static constant of [isHashMap](#rtvref.validation.isHashMap) + + +#### isHashMap.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [HASH_MAP](#rtvref.types.HASH_MAP) type. + +**Kind**: static method of [isHashMap](#rtvref.validation.isHashMap) +**Returns**: boolean - `true` if validated; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isInt : Module +Validation Module: isInt + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isInt](#rtvref.validation.isInt) : Module + * [.type](#rtvref.validation.isInt.type) : string + * [.default(v)](#rtvref.validation.isInt.default) ⇒ boolean + + + +#### isInt.type : string +Type: [INT](#rtvref.types.INT) + +**Kind**: static constant of [isInt](#rtvref.validation.isInt) + + +#### isInt.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [INT](#rtvref.types.INT) type. + +Determines if a value is an integer literal __only__ (i.e. a + [primitive](#rtvref.types.primitives)). It does not validate + `new Number(1)`, which is an object that is a number. + +**Kind**: static method of [isInt](#rtvref.validation.isInt) +**Returns**: boolean - `true` if validated; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isJson : Module +Validation Module: isJson + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isJson](#rtvref.validation.isJson) : Module + * [.type](#rtvref.validation.isJson.type) : string + * [.default(v)](#rtvref.validation.isJson.default) ⇒ boolean + + + +#### isJson.type : string +Type: [JSON](#rtvref.types.JSON) + +**Kind**: static constant of [isJson](#rtvref.validation.isJson) + + +#### isJson.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [JSON](#rtvref.types.JSON) type. + +**Kind**: static method of [isJson](#rtvref.validation.isJson) +**Returns**: boolean - `true` if validated; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isMap : Module +Validation Module: isMap + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isMap](#rtvref.validation.isMap) : Module + * [.type](#rtvref.validation.isMap.type) : string + * [.default(v)](#rtvref.validation.isMap.default) ⇒ boolean + + + +#### isMap.type : string +Type: [MAP](#rtvref.types.MAP) + +**Kind**: static constant of [isMap](#rtvref.validation.isMap) + + +#### isMap.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [MAP](#rtvref.types.MAP) type. + +**Kind**: static method of [isMap](#rtvref.validation.isMap) +**Returns**: boolean - `true` if validated; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isNull : Module +Validation Module: isNull + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isNull](#rtvref.validation.isNull) : Module + * [.type](#rtvref.validation.isNull.type) : string + * [.default(v)](#rtvref.validation.isNull.default) ⇒ boolean + + + +#### isNull.type : string +Type: [NULL](#rtvref.types.NULL) + +**Kind**: static constant of [isNull](#rtvref.validation.isNull) + + +#### isNull.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [NULL](#rtvref.types.NULL) type. + +**Kind**: static method of [isNull](#rtvref.validation.isNull) +**Returns**: boolean - `true` if validated; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isNumber : Module +Validation Module: isNumber + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isNumber](#rtvref.validation.isNumber) : Module + * [.type](#rtvref.validation.isNumber.type) : string + * [.default(v)](#rtvref.validation.isNumber.default) ⇒ boolean + + + +#### isNumber.type : string +Type: [NUMBER](#rtvref.types.NUMBER) + +**Kind**: static constant of [isNumber](#rtvref.validation.isNumber) + + +#### isNumber.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [NUMBER](#rtvref.types.NUMBER) type. + +Determines if a value is a number literal __only__ (i.e. a + [primitive](#rtvref.types.primitives)). It does not validate + `new Number(1)`, which is an object that is a number, neither does it + validate `NaN`. + +**Kind**: static method of [isNumber](#rtvref.validation.isNumber) +**Returns**: boolean - `true` if validated; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isObject : Module +Validation Module: isObject + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isObject](#rtvref.validation.isObject) : Module + * [.type](#rtvref.validation.isObject.type) : string + * [.default(v)](#rtvref.validation.isObject.default) ⇒ boolean + + + +#### isObject.type : string +Type: [OBJECT](#rtvref.types.OBJECT) + +**Kind**: static constant of [isObject](#rtvref.validation.isObject) + + +#### isObject.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [OBJECT](#rtvref.types.OBJECT) type. + +**Kind**: static method of [isObject](#rtvref.validation.isObject) +**Returns**: boolean - `true` if validated; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isPlainObject : Module +Validation Module: isPlainObject + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isPlainObject](#rtvref.validation.isPlainObject) : Module + * [.type](#rtvref.validation.isPlainObject.type) : string + * [.default(v)](#rtvref.validation.isPlainObject.default) ⇒ boolean + + + +#### isPlainObject.type : string +Type: [PLAIN_OBJECT](#rtvref.types.PLAIN_OBJECT) + +**Kind**: static constant of [isPlainObject](#rtvref.validation.isPlainObject) + + +#### isPlainObject.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [PLAIN_OBJECT](#rtvref.types.PLAIN_OBJECT) type. + +**Kind**: static method of [isPlainObject](#rtvref.validation.isPlainObject) +**Returns**: boolean - `true` if validated; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isPrimitive : Module +Validation Module: isPrimitive + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isPrimitive](#rtvref.validation.isPrimitive) : Module + * [.type](#rtvref.validation.isPrimitive.type) : string + * [.default(v)](#rtvref.validation.isPrimitive.default) ⇒ boolean + + + +#### isPrimitive.type : string +Type: `undefined`, [primitive](#rtvref.types.primitives) pseudo-type. + +**Kind**: static constant of [isPrimitive](#rtvref.validation.isPrimitive) + + +#### isPrimitive.default(v) ⇒ boolean +Determines if a value is a JavaScript [primitive](#rtvref.types.primitives). + +**Kind**: static method of [isPrimitive](#rtvref.validation.isPrimitive) +**Returns**: boolean - `true` if it is; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isPromise : Module +Validation Module: isPromise + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isPromise](#rtvref.validation.isPromise) : Module + * [.type](#rtvref.validation.isPromise.type) : string + * [.default(v)](#rtvref.validation.isPromise.default) ⇒ boolean + + + +#### isPromise.type : string +Type: [PROMISE](#rtvref.types.PROMISE) + +**Kind**: static constant of [isPromise](#rtvref.validation.isPromise) + + +#### isPromise.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [PROMISE](#rtvref.types.PROMISE) type. + +**Kind**: static method of [isPromise](#rtvref.validation.isPromise) +**Returns**: boolean - `true` if validated; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isRegExp : Module +Validation Module: isRegExp + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isRegExp](#rtvref.validation.isRegExp) : Module + * [.type](#rtvref.validation.isRegExp.type) : string + * [.default(v)](#rtvref.validation.isRegExp.default) ⇒ boolean + + + +#### isRegExp.type : string +Type: [REGEXP](#rtvref.types.REGEXP) + +**Kind**: static constant of [isRegExp](#rtvref.validation.isRegExp) + + +#### isRegExp.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [REGEXP](#rtvref.types.REGEXP) type. + +**Kind**: static method of [isRegExp](#rtvref.validation.isRegExp) +**Returns**: boolean - `true` if validated; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isSafeInt : Module +Validation Module: isSafeInt + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isSafeInt](#rtvref.validation.isSafeInt) : Module + * [.type](#rtvref.validation.isSafeInt.type) : string + * [.default(v)](#rtvref.validation.isSafeInt.default) ⇒ boolean + + + +#### isSafeInt.type : string +Type: [SAFE_INT](#rtvref.types.SAFE_INT) + +**Kind**: static constant of [isSafeInt](#rtvref.validation.isSafeInt) + + +#### isSafeInt.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [SAFE_INT](#rtvref.types.SAFE_INT) type. + +Determines if a value is an integer literal __only__ (i.e. a + [primitive](#rtvref.types.primitives)). It does not validate + `new Number(1)`, which is an object that is a number. + +**Kind**: static method of [isSafeInt](#rtvref.validation.isSafeInt) +**Returns**: boolean - `true` if validated; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isSet : Module +Validation Module: isSet + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isSet](#rtvref.validation.isSet) : Module + * [.type](#rtvref.validation.isSet.type) : string + * [.default(v)](#rtvref.validation.isSet.default) ⇒ boolean + + + +#### isSet.type : string +Type: [SET](#rtvref.types.SET) + +**Kind**: static constant of [isSet](#rtvref.validation.isSet) + + +#### isSet.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [SET](#rtvref.types.SET) type. + +**Kind**: static method of [isSet](#rtvref.validation.isSet) +**Returns**: boolean - `true` if validated; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isShape : Module +Validation Module: isShape + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isShape](#rtvref.validation.isShape) : Module + * [.type](#rtvref.validation.isShape.type) : string + * [.default(v)](#rtvref.validation.isShape.default) ⇒ boolean + + + +#### isShape.type : string +Type: `undefined`, [shape](#rtvref.types.shape_descriptor) pseudo-type. + +**Kind**: static constant of [isShape](#rtvref.validation.isShape) + + +#### isShape.default(v) ⇒ boolean +Determines if a value is a [shape](#rtvref.types.shape_descriptor). + +**Kind**: static method of [isShape](#rtvref.validation.isShape) +**Returns**: boolean - `true` if it is; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isString : Module +Validation Module: isString + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isString](#rtvref.validation.isString) : Module + * [.type](#rtvref.validation.isString.type) : string + * [.default(v, [options])](#rtvref.validation.isString.default) ⇒ boolean + + + +#### isString.type : string +Type: [STRING](#rtvref.types.STRING) + +**Kind**: static constant of [isString](#rtvref.validation.isString) + + +#### isString.default(v, [options]) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [STRING](#rtvref.types.STRING) type. + +Determines if a value is a string literal __only__ (i.e. a + [primitive](#rtvref.types.primitives)), __including an empty string__. + It does not validate `new String('value')`, which is an object that is a + string. + +**Kind**: static method of [isString](#rtvref.validation.isString) +**Returns**: boolean - `true` if validated; `false` otherwise. + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| v | \* | | Value to validate. | +| [options] | Object | | Validation options. | +| [options.allowEmpty] | boolean | false | If truthy, empty strings are permitted. | + + + +### validation.isSymbol : Module +Validation Module: isSymbol + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isSymbol](#rtvref.validation.isSymbol) : Module + * [.type](#rtvref.validation.isSymbol.type) : string + * [.default(v)](#rtvref.validation.isSymbol.default) ⇒ boolean + + + +#### isSymbol.type : string +Type: [SYMBOL](#rtvref.types.SYMBOL) + +**Kind**: static constant of [isSymbol](#rtvref.validation.isSymbol) + + +#### isSymbol.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [SYMBOL](#rtvref.types.SYMBOL) type. + +**Kind**: static method of [isSymbol](#rtvref.validation.isSymbol) +**Returns**: boolean - `true` if validated; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isTypeArgs : Module +Validation Module: isTypeArgs + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isTypeArgs](#rtvref.validation.isTypeArgs) : Module + * [.type](#rtvref.validation.isTypeArgs.type) : string + * [.default(v)](#rtvref.validation.isTypeArgs.default) ⇒ boolean + + + +#### isTypeArgs.type : string +Type: `undefined`, [type arguments](#rtvref.types.type_arguments) pseudo-type. + +**Kind**: static constant of [isTypeArgs](#rtvref.validation.isTypeArgs) + + +#### isTypeArgs.default(v) ⇒ boolean +Determines if a value is a [type arguments](#rtvref.types.type_arguments) + object. + +**Kind**: static method of [isTypeArgs](#rtvref.validation.isTypeArgs) +**Returns**: boolean - `true` if it is; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isTypeset : Module +Validation Module: isTypeset + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isTypeset](#rtvref.validation.isTypeset) : Module + * [.type](#rtvref.validation.isTypeset.type) : string + * [.default(v, [options])](#rtvref.validation.isTypeset.default) ⇒ boolean + + + +#### isTypeset.type : string +Type: `undefined`, [typeset](#rtvref.types.typeset) pseudo-type. + +**Kind**: static constant of [isTypeset](#rtvref.validation.isTypeset) + + +#### isTypeset.default(v, [options]) ⇒ boolean +Determines if a value is a typeset. + +**Kind**: static method of [isTypeset](#rtvref.validation.isTypeset) +**Returns**: boolean - `true` if it is; `false` otherwise. +**See**: [typeset](#rtvref.types.typeset) + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| v | \* | | Value to validate. | +| [options] | Object | | Validation options. | +| [options.deep] | boolean | false | If truthy, deeply-validates any nested typesets. Note that typesets in nested shapes are also deeply-validated. | +| [options.fullyQualified] | boolean | false | If truthy, the typeset must be fully-qualified. | +| [options.failure] | string \| undefined | | (Output property) If an options object is specified, this property will be added and set to a failure message IIF the validation fails. | + + + +### validation.isWeakMap : Module +Validation Module: isWeakMap + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isWeakMap](#rtvref.validation.isWeakMap) : Module + * [.type](#rtvref.validation.isWeakMap.type) : string + * [.default(v)](#rtvref.validation.isWeakMap.default) ⇒ boolean + + + +#### isWeakMap.type : string +Type: [WEAK_MAP](#rtvref.types.WEAK_MAP) + +**Kind**: static constant of [isWeakMap](#rtvref.validation.isWeakMap) + + +#### isWeakMap.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [WEAK_MAP](#rtvref.types.WEAK_MAP) type. + +**Kind**: static method of [isWeakMap](#rtvref.validation.isWeakMap) +**Returns**: boolean - `true` if validated; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +### validation.isWeakSet : Module +Validation Module: isWeakSet + +**Kind**: static typedef of [validation](#rtvref.validation) + +* [.isWeakSet](#rtvref.validation.isWeakSet) : Module + * [.type](#rtvref.validation.isWeakSet.type) : string + * [.default(v)](#rtvref.validation.isWeakSet.default) ⇒ boolean + + + +#### isWeakSet.type : string +Type: [WEAK_SET](#rtvref.types.WEAK_SET) + +**Kind**: static constant of [isWeakSet](#rtvref.validation.isWeakSet) + + +#### isWeakSet.default(v) ⇒ boolean +[Validation](#rtvref.validation.method) for the + [WEAK_SET](#rtvref.types.WEAK_SET) type. + +**Kind**: static method of [isWeakSet](#rtvref.validation.isWeakSet) +**Returns**: boolean - `true` if validated; `false` otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | + + + +## rtvref.validator : object +

RTV.js Type Validators

+ +This namespace provides validators for each supported [type](#rtvref.types), + capable of fully validating a value against that type. Validators differ from + type _validations_ provided by the [validation](#rtvref.validation) + module in that validators verify a value against a single, specific type, + considering [qualifiers](#rtvref.qualifiers) as well as + [type arguments](#rtvref.types.type_arguments). + +__Every validator module must provide the following interface:__ + +- `{function} default` (the default export): The + [type validator](#rtvref.validator.type_validator) itself. +- `{string} type`: The [type](#rtvref.types) verified. +- `{function} config`: The + [configuration function](#rtvref.validator.validator_config). + +Validator modules should be named as `val` such that their default + export is named `val`. + +There can only be one validator for any given type. Where possible, each + validator should use applicable [type validations](#rtvref.validation) + rather than third-party code (e.g. lodash) to ensure that the semantics of + each type is properly interpreted. If the validator introduces an entirely + new type, then it should use whatever means necessary to properly identify + the type which it validates. + +**Kind**: static namespace of [rtvref](#rtvref) + +* [.validator](#rtvref.validator) : object + * [.type_validator(value, [qualifier], [args])](#rtvref.validator.type_validator) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.validator_config(settings)](#rtvref.validator.validator_config) + * [.valAny](#rtvref.validator.valAny) : Module + * [.type](#rtvref.validator.valAny.type) : string + * [.config(settings)](#rtvref.validator.valAny.config) + * [.default(v, [q])](#rtvref.validator.valAny.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valAnyObject](#rtvref.validator.valAnyObject) : Module + * [.type](#rtvref.validator.valAnyObject.type) : string + * [.config(settings)](#rtvref.validator.valAnyObject.config) + * [.default(v, [q], [args])](#rtvref.validator.valAnyObject.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valArray](#rtvref.validator.valArray) : Module + * [.type](#rtvref.validator.valArray.type) : string + * [.config(settings)](#rtvref.validator.valArray.config) + * [.default(v, [q], [args])](#rtvref.validator.valArray.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valBoolean](#rtvref.validator.valBoolean) : Module + * [.type](#rtvref.validator.valBoolean.type) : string + * [.config(settings)](#rtvref.validator.valBoolean.config) + * [.default(v, [q])](#rtvref.validator.valBoolean.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valClassObject](#rtvref.validator.valClassObject) : Module + * [.type](#rtvref.validator.valClassObject.type) : string + * [.config(settings)](#rtvref.validator.valClassObject.config) + * [.default(v, [q], [args])](#rtvref.validator.valClassObject.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valDate](#rtvref.validator.valDate) : Module + * [.type](#rtvref.validator.valDate.type) : string + * [.config(settings)](#rtvref.validator.valDate.config) + * [.default(v, [q])](#rtvref.validator.valDate.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valError](#rtvref.validator.valError) : Module + * [.type](#rtvref.validator.valError.type) : string + * [.config(settings)](#rtvref.validator.valError.config) + * [.default(v, [q])](#rtvref.validator.valError.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valFinite](#rtvref.validator.valFinite) : Module + * [.type](#rtvref.validator.valFinite.type) : string + * [.config(settings)](#rtvref.validator.valFinite.config) + * [.default(v, [q], [args])](#rtvref.validator.valFinite.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valFloat](#rtvref.validator.valFloat) : Module + * [.type](#rtvref.validator.valFloat.type) : string + * [.config(settings)](#rtvref.validator.valFloat.config) + * [.default(v, [q], [args])](#rtvref.validator.valFloat.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valFunction](#rtvref.validator.valFunction) : Module + * [.type](#rtvref.validator.valFunction.type) : string + * [.config(settings)](#rtvref.validator.valFunction.config) + * [.default(v, [q])](#rtvref.validator.valFunction.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valHashMap](#rtvref.validator.valHashMap) : Module + * [.type](#rtvref.validator.valHashMap.type) : string + * [.config(settings)](#rtvref.validator.valHashMap.config) + * [.default(v, [q], [args])](#rtvref.validator.valHashMap.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valInt](#rtvref.validator.valInt) : Module + * [.type](#rtvref.validator.valInt.type) : string + * [.config(settings)](#rtvref.validator.valInt.config) + * [.default(v, [q], [args])](#rtvref.validator.valInt.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valJson](#rtvref.validator.valJson) : Module + * [.type](#rtvref.validator.valJson.type) : string + * [.config(settings)](#rtvref.validator.valJson.config) + * [.default(v, [q])](#rtvref.validator.valJson.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valMap](#rtvref.validator.valMap) : Module + * [.type](#rtvref.validator.valMap.type) : string + * [.config(settings)](#rtvref.validator.valMap.config) + * [.default(v, [q], [args])](#rtvref.validator.valMap.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valNull](#rtvref.validator.valNull) : Module + * [.type](#rtvref.validator.valNull.type) : string + * [.config(settings)](#rtvref.validator.valNull.config) + * [.default(v, [q])](#rtvref.validator.valNull.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valNumber](#rtvref.validator.valNumber) : Module + * [.type](#rtvref.validator.valNumber.type) : string + * [.config(settings)](#rtvref.validator.valNumber.config) + * [.default(v, [q], [args])](#rtvref.validator.valNumber.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valObject](#rtvref.validator.valObject) : Module + * [.type](#rtvref.validator.valObject.type) : string + * [.config(settings)](#rtvref.validator.valObject.config) + * [.default(v, [q], [args])](#rtvref.validator.valObject.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valPlainObject](#rtvref.validator.valPlainObject) : Module + * [.type](#rtvref.validator.valPlainObject.type) : string + * [.config(settings)](#rtvref.validator.valPlainObject.config) + * [.default(v, [q], [args])](#rtvref.validator.valPlainObject.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valPromise](#rtvref.validator.valPromise) : Module + * [.type](#rtvref.validator.valPromise.type) : string + * [.config(settings)](#rtvref.validator.valPromise.config) + * [.default(v, [q])](#rtvref.validator.valPromise.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valRegExp](#rtvref.validator.valRegExp) : Module + * [.type](#rtvref.validator.valRegExp.type) : string + * [.config(settings)](#rtvref.validator.valRegExp.config) + * [.default(v, [q])](#rtvref.validator.valRegExp.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valSafeInt](#rtvref.validator.valSafeInt) : Module + * [.type](#rtvref.validator.valSafeInt.type) : string + * [.config(settings)](#rtvref.validator.valSafeInt.config) + * [.default(v, [q], [args])](#rtvref.validator.valSafeInt.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valSet](#rtvref.validator.valSet) : Module + * [.type](#rtvref.validator.valSet.type) : string + * [.config(settings)](#rtvref.validator.valSet.config) + * [.default(v, [q], [args])](#rtvref.validator.valSet.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valString](#rtvref.validator.valString) : Module + * [.type](#rtvref.validator.valString.type) : string + * [.config(settings)](#rtvref.validator.valString.config) + * [.default(v, [q], [args])](#rtvref.validator.valString.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valSymbol](#rtvref.validator.valSymbol) : Module + * [.type](#rtvref.validator.valSymbol.type) : string + * [.config(settings)](#rtvref.validator.valSymbol.config) + * [.default(v, [q], [args])](#rtvref.validator.valSymbol.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valWeakMap](#rtvref.validator.valWeakMap) : Module + * [.type](#rtvref.validator.valWeakMap.type) : string + * [.config(settings)](#rtvref.validator.valWeakMap.config) + * [.default(v, [q])](#rtvref.validator.valWeakMap.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.valWeakSet](#rtvref.validator.valWeakSet) : Module + * [.type](#rtvref.validator.valWeakSet.type) : string + * [.config(settings)](#rtvref.validator.valWeakSet.config) + * [.default(v, [q])](#rtvref.validator.valWeakSet.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + * [.validator_config_settings](#rtvref.validator.validator_config_settings) : Object + + + +### validator.type_validator(value, [qualifier], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +

Type Validator Function

+ +NOTE: A validator must always give __precedence__ to + [qualifier rules](#rtvref.types.qualifier_rules) for the type it's + validating, over any arguments specified. For example, + +__NOTE:__ A validator must support all its qualifier rules, including proper + handling of `null` values when [EXPECTED](#rtvref.qualifiers.EXPECTED) + and `undefined` values when [OPTIONAL](#rtvref.qualifiers.OPTIONAL), + __in addition to__ and type-specific qualifier rules. For example, the + [STRING](#rtvref.types.STRING) type permits empty strings when not + [REQUIRED](#rtvref.qualifiers.REQUIRED). + +**Kind**: static method of [validator](#rtvref.validator) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; + `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| value | \* | The value to validate. | +| [qualifier] | string | The validation qualifier from the immediate [typeset](#rtvref.types.typeset) in which the pertaining type was specified. Validators should always explicitly default to [REQUIRED](#rtvref.qualifiers.REQUIRED) to maintain consistent behavior. | +| [args] | Object | The arguments object, if any/applicable, for the type being validated. For example, [string args](#rtvref.types.STRING_args) in a typeset such as `[rtv.t.STRING, {min: 5}]` (a required string of at least 5 characters in length). | + + + +### validator.validator_config(settings) +

Type Validator Configuration Function

+ +This function is called to provide the + [type validator](#rtvref.validator.type_validator) with access to + internal utilities. + +**Kind**: static method of [validator](#rtvref.validator) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +### validator.valAny : Module +Validator Module: valAny + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valAny](#rtvref.validator.valAny) : Module + * [.type](#rtvref.validator.valAny.type) : string + * [.config(settings)](#rtvref.validator.valAny.config) + * [.default(v, [q])](#rtvref.validator.valAny.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valAny.type : string +Type: [ANY](#rtvref.types.ANY) + +**Kind**: static constant of [valAny](#rtvref.validator.valAny) + + +#### valAny.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valAny](#rtvref.validator.valAny) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valAny.default(v, [q]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [ANY](#rtvref.types.ANY) type. + +**Kind**: static method of [valAny](#rtvref.validator.valAny) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | + + + +### validator.valAnyObject : Module +Validator Module: valAnyObject + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valAnyObject](#rtvref.validator.valAnyObject) : Module + * [.type](#rtvref.validator.valAnyObject.type) : string + * [.config(settings)](#rtvref.validator.valAnyObject.config) + * [.default(v, [q], [args])](#rtvref.validator.valAnyObject.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valAnyObject.type : string +Type: [ANY_OBJECT](#rtvref.types.ANY_OBJECT) + +**Kind**: static constant of [valAnyObject](#rtvref.validator.valAnyObject) + + +#### valAnyObject.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valAnyObject](#rtvref.validator.valAnyObject) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valAnyObject.default(v, [q], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [ANY_OBJECT](#rtvref.types.ANY_OBJECT) type. + +**Kind**: static method of [valAnyObject](#rtvref.validator.valAnyObject) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | +| [args] | [numeric_args](#rtvref.types.numeric_args) | Type arguments. | + + + +### validator.valArray : Module +Validator Module: valArray + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valArray](#rtvref.validator.valArray) : Module + * [.type](#rtvref.validator.valArray.type) : string + * [.config(settings)](#rtvref.validator.valArray.config) + * [.default(v, [q], [args])](#rtvref.validator.valArray.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valArray.type : string +Type: [ARRAY](#rtvref.types.ARRAY) + +**Kind**: static constant of [valArray](#rtvref.validator.valArray) + + +#### valArray.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valArray](#rtvref.validator.valArray) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valArray.default(v, [q], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [ARRAY](#rtvref.types.ARRAY) type. + +**Kind**: static method of [valArray](#rtvref.validator.valArray) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | +| [args] | [ARRAY_args](#rtvref.types.ARRAY_args) | Type arguments. | + + + +### validator.valBoolean : Module +Validator Module: valBoolean + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valBoolean](#rtvref.validator.valBoolean) : Module + * [.type](#rtvref.validator.valBoolean.type) : string + * [.config(settings)](#rtvref.validator.valBoolean.config) + * [.default(v, [q])](#rtvref.validator.valBoolean.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valBoolean.type : string +Type: [BOOLEAN](#rtvref.types.BOOLEAN) + +**Kind**: static constant of [valBoolean](#rtvref.validator.valBoolean) + + +#### valBoolean.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valBoolean](#rtvref.validator.valBoolean) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valBoolean.default(v, [q]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [BOOLEAN](#rtvref.types.BOOLEAN) type. + +Determines if a value is a boolean literal __only__ (i.e. a + [primitive](#rtvref.types.primitives)). It does not validate + `new Boolean(true)`, which is an object that is a boolean. + +**Kind**: static method of [valBoolean](#rtvref.validator.valBoolean) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | + + + +### validator.valClassObject : Module +Validator Module: valClassObject + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valClassObject](#rtvref.validator.valClassObject) : Module + * [.type](#rtvref.validator.valClassObject.type) : string + * [.config(settings)](#rtvref.validator.valClassObject.config) + * [.default(v, [q], [args])](#rtvref.validator.valClassObject.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valClassObject.type : string +Type: [CLASS_OBJECT](#rtvref.types.CLASS_OBJECT) + +**Kind**: static constant of [valClassObject](#rtvref.validator.valClassObject) + + +#### valClassObject.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valClassObject](#rtvref.validator.valClassObject) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valClassObject.default(v, [q], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [CLASS_OBJECT](#rtvref.types.CLASS_OBJECT) type. + +**Kind**: static method of [valClassObject](#rtvref.validator.valClassObject) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | +| [args] | [numeric_args](#rtvref.types.numeric_args) | Type arguments. | + + + +### validator.valDate : Module +Validator Module: valDate + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valDate](#rtvref.validator.valDate) : Module + * [.type](#rtvref.validator.valDate.type) : string + * [.config(settings)](#rtvref.validator.valDate.config) + * [.default(v, [q])](#rtvref.validator.valDate.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valDate.type : string +Type: [DATE](#rtvref.types.DATE) + +**Kind**: static constant of [valDate](#rtvref.validator.valDate) + + +#### valDate.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valDate](#rtvref.validator.valDate) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valDate.default(v, [q]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [DATE](#rtvref.types.DATE) type. + +**Kind**: static method of [valDate](#rtvref.validator.valDate) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | + + + +### validator.valError : Module +Validator Module: valError + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valError](#rtvref.validator.valError) : Module + * [.type](#rtvref.validator.valError.type) : string + * [.config(settings)](#rtvref.validator.valError.config) + * [.default(v, [q])](#rtvref.validator.valError.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valError.type : string +Type: [ERROR](#rtvref.types.ERROR) + +**Kind**: static constant of [valError](#rtvref.validator.valError) + + +#### valError.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valError](#rtvref.validator.valError) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valError.default(v, [q]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [ERROR](#rtvref.types.ERROR) type. + +**Kind**: static method of [valError](#rtvref.validator.valError) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | + + + +### validator.valFinite : Module +Validator Module: valFinite + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valFinite](#rtvref.validator.valFinite) : Module + * [.type](#rtvref.validator.valFinite.type) : string + * [.config(settings)](#rtvref.validator.valFinite.config) + * [.default(v, [q], [args])](#rtvref.validator.valFinite.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valFinite.type : string +Type: [FINITE](#rtvref.types.FINITE) + +**Kind**: static constant of [valFinite](#rtvref.validator.valFinite) + + +#### valFinite.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valFinite](#rtvref.validator.valFinite) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valFinite.default(v, [q], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [FINITE](#rtvref.types.FINITE) type. + +Determines if a value is a number literal __only__ (i.e. a + [primitive](#rtvref.types.primitives)). It does not validate + `new Number(1)`, which is an object that is a number. + +**Kind**: static method of [valFinite](#rtvref.validator.valFinite) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | +| [args] | [numeric_args](#rtvref.types.numeric_args) | Type arguments. | + + + +### validator.valFloat : Module +Validator Module: valFloat + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valFloat](#rtvref.validator.valFloat) : Module + * [.type](#rtvref.validator.valFloat.type) : string + * [.config(settings)](#rtvref.validator.valFloat.config) + * [.default(v, [q], [args])](#rtvref.validator.valFloat.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valFloat.type : string +Type: [FLOAT](#rtvref.types.FLOAT) + +**Kind**: static constant of [valFloat](#rtvref.validator.valFloat) + + +#### valFloat.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valFloat](#rtvref.validator.valFloat) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valFloat.default(v, [q], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [FLOAT](#rtvref.types.FLOAT) type. + +Determines if a value is a number literal __only__ (i.e. a + [primitive](#rtvref.types.primitives)). It does not validate + `new Number(1.5)`, which is an object that is a number. + +**Kind**: static method of [valFloat](#rtvref.validator.valFloat) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | +| [args] | [numeric_args](#rtvref.types.numeric_args) | Type arguments. | + + + +### validator.valFunction : Module +Validator Module: valFunction + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valFunction](#rtvref.validator.valFunction) : Module + * [.type](#rtvref.validator.valFunction.type) : string + * [.config(settings)](#rtvref.validator.valFunction.config) + * [.default(v, [q])](#rtvref.validator.valFunction.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valFunction.type : string +Type: [FUNCTION](#rtvref.types.FUNCTION) + +**Kind**: static constant of [valFunction](#rtvref.validator.valFunction) + + +#### valFunction.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valFunction](#rtvref.validator.valFunction) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valFunction.default(v, [q]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [FUNCTION](#rtvref.types.FUNCTION) type. + +**Kind**: static method of [valFunction](#rtvref.validator.valFunction) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | + + + +### validator.valHashMap : Module +Validator Module: valHashMap + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valHashMap](#rtvref.validator.valHashMap) : Module + * [.type](#rtvref.validator.valHashMap.type) : string + * [.config(settings)](#rtvref.validator.valHashMap.config) + * [.default(v, [q], [args])](#rtvref.validator.valHashMap.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valHashMap.type : string +Type: [HASH_MAP](#rtvref.types.HASH_MAP) + +**Kind**: static constant of [valHashMap](#rtvref.validator.valHashMap) + + +#### valHashMap.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valHashMap](#rtvref.validator.valHashMap) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valHashMap.default(v, [q], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [HASH_MAP](#rtvref.types.HASH_MAP) type. + +**Kind**: static method of [valHashMap](#rtvref.validator.valHashMap) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | +| [args] | [collection_args](#rtvref.types.collection_args) | Type arguments. | + + + +### validator.valInt : Module +Validator Module: valInt + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valInt](#rtvref.validator.valInt) : Module + * [.type](#rtvref.validator.valInt.type) : string + * [.config(settings)](#rtvref.validator.valInt.config) + * [.default(v, [q], [args])](#rtvref.validator.valInt.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valInt.type : string +Type: [INT](#rtvref.types.INT) + +**Kind**: static constant of [valInt](#rtvref.validator.valInt) + + +#### valInt.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valInt](#rtvref.validator.valInt) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valInt.default(v, [q], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [INT](#rtvref.types.INT) type. + +Determines if a value is a number literal __only__ (i.e. a + [primitive](#rtvref.types.primitives)). It does not validate + `new Number(1)`, which is an object that is a number. + +**Kind**: static method of [valInt](#rtvref.validator.valInt) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | +| [args] | [numeric_args](#rtvref.types.numeric_args) | Type arguments. | + + + +### validator.valJson : Module +Validator Module: valJson + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valJson](#rtvref.validator.valJson) : Module + * [.type](#rtvref.validator.valJson.type) : string + * [.config(settings)](#rtvref.validator.valJson.config) + * [.default(v, [q])](#rtvref.validator.valJson.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valJson.type : string +Type: [JSON](#rtvref.types.JSON) + +**Kind**: static constant of [valJson](#rtvref.validator.valJson) + + +#### valJson.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valJson](#rtvref.validator.valJson) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valJson.default(v, [q]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [JSON](#rtvref.types.JSON) type. + +**Kind**: static method of [valJson](#rtvref.validator.valJson) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | + + + +### validator.valMap : Module +Validator Module: valMap + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valMap](#rtvref.validator.valMap) : Module + * [.type](#rtvref.validator.valMap.type) : string + * [.config(settings)](#rtvref.validator.valMap.config) + * [.default(v, [q], [args])](#rtvref.validator.valMap.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valMap.type : string +Type: [MAP](#rtvref.types.MAP) + +**Kind**: static constant of [valMap](#rtvref.validator.valMap) + + +#### valMap.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valMap](#rtvref.validator.valMap) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valMap.default(v, [q], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [MAP](#rtvref.types.MAP) type. + +**Kind**: static method of [valMap](#rtvref.validator.valMap) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | +| [args] | [collection_args](#rtvref.types.collection_args) | Type arguments. | + + + +### validator.valNull : Module +Validator Module: valNull + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valNull](#rtvref.validator.valNull) : Module + * [.type](#rtvref.validator.valNull.type) : string + * [.config(settings)](#rtvref.validator.valNull.config) + * [.default(v, [q])](#rtvref.validator.valNull.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valNull.type : string +Type: [NULL](#rtvref.types.NULL) + +**Kind**: static constant of [valNull](#rtvref.validator.valNull) + + +#### valNull.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valNull](#rtvref.validator.valNull) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valNull.default(v, [q]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [NULL](#rtvref.types.NULL) type. + +**Kind**: static method of [valNull](#rtvref.validator.valNull) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | + + + +### validator.valNumber : Module +Validator Module: valNumber + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valNumber](#rtvref.validator.valNumber) : Module + * [.type](#rtvref.validator.valNumber.type) : string + * [.config(settings)](#rtvref.validator.valNumber.config) + * [.default(v, [q], [args])](#rtvref.validator.valNumber.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valNumber.type : string +Type: [NUMBER](#rtvref.types.NUMBER) + +**Kind**: static constant of [valNumber](#rtvref.validator.valNumber) + + +#### valNumber.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valNumber](#rtvref.validator.valNumber) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valNumber.default(v, [q], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [NUMBER](#rtvref.types.NUMBER) type. + +Determines if a value is a number literal __only__ (i.e. a + [primitive](#rtvref.types.primitives)). It does not validate + `new Number(1)`, which is an object that is a number. + +**Kind**: static method of [valNumber](#rtvref.validator.valNumber) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | +| [args] | [numeric_args](#rtvref.types.numeric_args) | Type arguments. | + + + +### validator.valObject : Module +Validator Module: valObject + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valObject](#rtvref.validator.valObject) : Module + * [.type](#rtvref.validator.valObject.type) : string + * [.config(settings)](#rtvref.validator.valObject.config) + * [.default(v, [q], [args])](#rtvref.validator.valObject.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valObject.type : string +Type: [OBJECT](#rtvref.types.OBJECT) + +**Kind**: static constant of [valObject](#rtvref.validator.valObject) + + +#### valObject.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valObject](#rtvref.validator.valObject) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valObject.default(v, [q], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [OBJECT](#rtvref.types.OBJECT) type. + +**Kind**: static method of [valObject](#rtvref.validator.valObject) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | +| [args] | [numeric_args](#rtvref.types.numeric_args) | Type arguments. | + + + +### validator.valPlainObject : Module +Validator Module: valPlainObject + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valPlainObject](#rtvref.validator.valPlainObject) : Module + * [.type](#rtvref.validator.valPlainObject.type) : string + * [.config(settings)](#rtvref.validator.valPlainObject.config) + * [.default(v, [q], [args])](#rtvref.validator.valPlainObject.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valPlainObject.type : string +Type: [PLAIN_OBJECT](#rtvref.types.PLAIN_OBJECT) + +**Kind**: static constant of [valPlainObject](#rtvref.validator.valPlainObject) + + +#### valPlainObject.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valPlainObject](#rtvref.validator.valPlainObject) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valPlainObject.default(v, [q], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [PLAIN_OBJECT](#rtvref.types.PLAIN_OBJECT) type. + +**Kind**: static method of [valPlainObject](#rtvref.validator.valPlainObject) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | +| [args] | [numeric_args](#rtvref.types.numeric_args) | Type arguments. | + + + +### validator.valPromise : Module +Validator Module: valPromise + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valPromise](#rtvref.validator.valPromise) : Module + * [.type](#rtvref.validator.valPromise.type) : string + * [.config(settings)](#rtvref.validator.valPromise.config) + * [.default(v, [q])](#rtvref.validator.valPromise.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valPromise.type : string +Type: [PROMISE](#rtvref.types.PROMISE) + +**Kind**: static constant of [valPromise](#rtvref.validator.valPromise) + + +#### valPromise.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valPromise](#rtvref.validator.valPromise) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valPromise.default(v, [q]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [PROMISE](#rtvref.types.PROMISE) type. + +**Kind**: static method of [valPromise](#rtvref.validator.valPromise) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | + + + +### validator.valRegExp : Module +Validator Module: valRegExp + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valRegExp](#rtvref.validator.valRegExp) : Module + * [.type](#rtvref.validator.valRegExp.type) : string + * [.config(settings)](#rtvref.validator.valRegExp.config) + * [.default(v, [q])](#rtvref.validator.valRegExp.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valRegExp.type : string +Type: [REGEXP](#rtvref.types.REGEXP) + +**Kind**: static constant of [valRegExp](#rtvref.validator.valRegExp) + + +#### valRegExp.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valRegExp](#rtvref.validator.valRegExp) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valRegExp.default(v, [q]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [REGEXP](#rtvref.types.REGEXP) type. + +**Kind**: static method of [valRegExp](#rtvref.validator.valRegExp) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | + + + +### validator.valSafeInt : Module +Validator Module: valSafeInt + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valSafeInt](#rtvref.validator.valSafeInt) : Module + * [.type](#rtvref.validator.valSafeInt.type) : string + * [.config(settings)](#rtvref.validator.valSafeInt.config) + * [.default(v, [q], [args])](#rtvref.validator.valSafeInt.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valSafeInt.type : string +Type: [SAFE_INT](#rtvref.types.SAFE_INT) + +**Kind**: static constant of [valSafeInt](#rtvref.validator.valSafeInt) + + +#### valSafeInt.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valSafeInt](#rtvref.validator.valSafeInt) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valSafeInt.default(v, [q], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [SAFE_INT](#rtvref.types.SAFE_INT) type. + +Determines if a value is a number literal __only__ (i.e. a + [primitive](#rtvref.types.primitives)). It does not validate + `new Number(1)`, which is an object that is a number. + +**Kind**: static method of [valSafeInt](#rtvref.validator.valSafeInt) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | +| [args] | [numeric_args](#rtvref.types.numeric_args) | Type arguments. | + + + +### validator.valSet : Module +Validator Module: valSet + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valSet](#rtvref.validator.valSet) : Module + * [.type](#rtvref.validator.valSet.type) : string + * [.config(settings)](#rtvref.validator.valSet.config) + * [.default(v, [q], [args])](#rtvref.validator.valSet.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valSet.type : string +Type: [SET](#rtvref.types.SET) + +**Kind**: static constant of [valSet](#rtvref.validator.valSet) + + +#### valSet.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valSet](#rtvref.validator.valSet) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valSet.default(v, [q], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [SET](#rtvref.types.SET) type. + +**Kind**: static method of [valSet](#rtvref.validator.valSet) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | +| [args] | [collection_args](#rtvref.types.collection_args) | Type arguments. | + + + +### validator.valString : Module +Validator Module: valString + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valString](#rtvref.validator.valString) : Module + * [.type](#rtvref.validator.valString.type) : string + * [.config(settings)](#rtvref.validator.valString.config) + * [.default(v, [q], [args])](#rtvref.validator.valString.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valString.type : string +Type: [STRING](#rtvref.types.STRING) + +**Kind**: static constant of [valString](#rtvref.validator.valString) + + +#### valString.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valString](#rtvref.validator.valString) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valString.default(v, [q], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [STRING](#rtvref.types.STRING) type. + +Determines if a value is a string literal __only__ (i.e. a + [primitive](#rtvref.types.primitives)). It does not validate + `new String('value')`, which is an object that is a string. + +**Kind**: static method of [valString](#rtvref.validator.valString) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | +| [args] | [STRING_args](#rtvref.types.STRING_args) | Type arguments. | + + + +### validator.valSymbol : Module +Validator Module: valSymbol + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valSymbol](#rtvref.validator.valSymbol) : Module + * [.type](#rtvref.validator.valSymbol.type) : string + * [.config(settings)](#rtvref.validator.valSymbol.config) + * [.default(v, [q], [args])](#rtvref.validator.valSymbol.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valSymbol.type : string +Type: [SYMBOL](#rtvref.types.SYMBOL) + +**Kind**: static constant of [valSymbol](#rtvref.validator.valSymbol) + + +#### valSymbol.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valSymbol](#rtvref.validator.valSymbol) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valSymbol.default(v, [q], [args]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [SYMBOL](#rtvref.types.SYMBOL) type. + +**Kind**: static method of [valSymbol](#rtvref.validator.valSymbol) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | +| [args] | [numeric_args](#rtvref.types.numeric_args) | Type arguments. | + + + +### validator.valWeakMap : Module +Validator Module: valWeakMap + +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valWeakMap](#rtvref.validator.valWeakMap) : Module + * [.type](#rtvref.validator.valWeakMap.type) : string + * [.config(settings)](#rtvref.validator.valWeakMap.config) + * [.default(v, [q])](#rtvref.validator.valWeakMap.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valWeakMap.type : string +Type: [WEAK_MAP](#rtvref.types.WEAK_MAP) + +**Kind**: static constant of [valWeakMap](#rtvref.validator.valWeakMap) + + +#### valWeakMap.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valWeakMap](#rtvref.validator.valWeakMap) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valWeakMap.default(v, [q]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [WEAK_MAP](#rtvref.types.WEAK_MAP) type. + +**Kind**: static method of [valWeakMap](#rtvref.validator.valWeakMap) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | + + +### validator.valWeakSet : Module +Validator Module: valWeakSet -* * * +**Kind**: static typedef of [validator](#rtvref.validator) + +* [.valWeakSet](#rtvref.validator.valWeakSet) : Module + * [.type](#rtvref.validator.valWeakSet.type) : string + * [.config(settings)](#rtvref.validator.valWeakSet.config) + * [.default(v, [q])](#rtvref.validator.valWeakSet.default) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) + + + +#### valWeakSet.type : string +Type: [WEAK_SET](#rtvref.types.WEAK_SET) + +**Kind**: static constant of [valWeakSet](#rtvref.validator.valWeakSet) + + +#### valWeakSet.config(settings) +[Configuration Function](#rtvref.validator.validator_config) + +**Kind**: static method of [valWeakSet](#rtvref.validator.valWeakSet) + +| Param | Type | Description | +| --- | --- | --- | +| settings | [validator_config_settings](#rtvref.validator.validator_config_settings) | Configuration settings. | + + + +#### valWeakSet.default(v, [q]) ⇒ [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) +[Validator](#rtvref.validator.type_validator) for the + [WEAK_SET](#rtvref.types.WEAK_SET) type. + +**Kind**: static method of [valWeakSet](#rtvref.validator.valWeakSet) +**Returns**: [RtvSuccess](#rtvref.RtvSuccess) \| [RtvError](#rtvref.RtvError) - An `RtvSuccess` if valid; `RtvError` if not. + +| Param | Type | Description | +| --- | --- | --- | +| v | \* | Value to validate. | +| [q] | string | Validation qualifier. Defaults to [REQUIRED](#rtvref.qualifiers.REQUIRED). | + + + +### validator.validator_config_settings : Object +

Type Validator Configuration Settings

+ +The settings provided to the + [configuration function](#rtvref.validator.validator_config). + +**Kind**: static typedef of [validator](#rtvref.validator) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| impl | [impl](#rtvref.impl) | Reference to the `impl` module. | diff --git a/README.md b/README.md index c316a95..002f9da 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # RTV.js -__Runtime Type Verification Isomorphic JavaScript Library__ +Runtime Verification Library for browsers and Node.js. -This library runs equally well in modern browsers and on the server with Node.js. +This library is isomorphic: It runs equally well in modern browsers and on the server with Node.js. # Goals @@ -31,12 +31,9 @@ Shapes must be: # TODO -- [ ] Implement the library... - - [ ] Debug the generated docs (including private docs), checking for broken links... - [ ] Unit tests must be run both in the browser and in Node.js -- in the browser via Gitlab CI - [ ] Add Gitlab CI config, or use TravisCI? - [ ] Publish to npm - - [ ] Add `.npmignore` - [ ] Make sure 'Goals' section is complete and accurate, add some links - [ ] Make sure `CONTRIBUTING.md` is filled-out diff --git a/package.json b/package.json index 2499a2a..b98ad3e 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "node:internals": "rollup -c tools/rollup.internals.js && node -r ./dist_tools/internals.js --inspect", "build:lib": "BABEL_ENV=build rollup -c", "build": "npm run clean && npm run build:lib", - "docs": "jsdoc2md -f \"src/**/*.js\" -f \"src/**/*.jsdoc\" --separators > API.md", + "docs": "jsdoc2md -f \"src/**/*.js\" -f \"src/**/*.jsdoc\" --heading-depth 1 > API.md", "lint": "eslint ./*.js \"src/**/*.js\" \"test/**/*.js\" \"tools/**/*.js\"", "test:unit": "BABEL_ENV=test mocha -c -r mocha-setup.js \"./test/**/*.test.js\"", "test:unit:watch": "npm run test:unit -- -w", diff --git a/src/lib/impl.js b/src/lib/impl.js index 34980d9..c9ad527 100644 --- a/src/lib/impl.js +++ b/src/lib/impl.js @@ -11,7 +11,7 @@ import isBoolean from './validation/isBoolean'; import isTypeset from './validation/isTypeset'; import isShape from './validation/isShape'; import isTypeArgs from './validation/isTypeArgs'; -import isValidator from './validation/isValidator'; +import isCustomValidator from './validation/isCustomValidator'; import {DEFAULT_OBJECT_TYPE, argTypes, default as types} from './types'; import {DEFAULT_QUALIFIER, default as qualifiers} from './qualifiers'; @@ -20,7 +20,7 @@ import RtvSuccess from './RtvSuccess'; import RtvError from './RtvError'; /** - *

RTV Implementation Module

+ *

RTV.js Implementation

* * Provides the internal implementation for the externally-facing {@link rtv RTV} * API, as well as utilities for {@link rtvref.validator type validators}. @@ -220,7 +220,7 @@ const fullyQualify = function(typeset, qualifier) { } // if a validator, it has an implied type of ANY - if (isValidator(typeset)) { + if (isCustomValidator(typeset)) { return [qualifier, types.ANY, typeset]; } @@ -255,7 +255,7 @@ const fullyQualify = function(typeset, qualifier) { } else if (isTypeArgs(rule)) { // args for curType since typeset is an array and object is not in first position fqts.push(rule); - } else if (isValidator(rule)) { + } else if (isCustomValidator(rule)) { // validator: ANY is implied type if none specified if (!curType) { curType = types.ANY; @@ -396,8 +396,8 @@ const extractNextType = function(typeset, qualifier) { * should be attributed to the subtype rather than the * {@link rtvref.qualifiers.DEFAULT_QUALIFIER default qualifier}. * @see {@link rtvref.impl.check} - * @see {@link rtvref.impl.checkShape} - * @see {@link rtvref.impl.checkType} + * @see {@link rtvref.impl.checkWithShape} + * @see {@link rtvref.impl.checkWithType} */ /** @@ -412,8 +412,8 @@ const extractNextType = function(typeset, qualifier) { * returned may contain references to objects in `given` depending on property * types. * @see {@link rtvref.impl.check} - * @see {@link rtvref.impl.checkShape} - * @see {@link rtvref.impl.checkType} + * @see {@link rtvref.impl.checkWithShape} + * @see {@link rtvref.impl.checkWithType} * @throws {Error} If `current.path` or `override.path` is specified and not an array. */ const _getCheckOptions = function(current = {}, override = {}) { @@ -444,7 +444,7 @@ const _getCheckOptions = function(current = {}, override = {}) { /** * Checks a value using a single type. - * @function rtvref.impl.checkType + * @function rtvref.impl.checkWithType * @param {*} value Value to check. * @param {rtvref.types.typeset} singleType Either a simple type name (one of * {@link rtvref.types.types}), a {@link rtvref.types.shape_descriptor shape descriptor}, @@ -523,7 +523,7 @@ const checkWithType = function(value, singleType /*, options*/) { /** * Checks a value using a {@link rtvref.types.shape_descriptor shape descriptor} and * ensure the value's type is the default object type. - * @function rtvref.impl.checkShape + * @function rtvref.impl.checkWithShape * @param {Object} value Value to check. Must be of the * {@link rtvref.types.DEFAULT_OBJECT_TYPE default} object type. * @param {Object} shape Expected shape of the `value`. Must be an @@ -546,27 +546,28 @@ const checkWithShape = function(value, shape /*, options*/) { /** * Checks a value using an Array typeset. - * @function rtvref.impl.checkTypeset + * @function rtvref.impl.checkWithArray * @param {*} value Value to check. - * @param {rtvref.types.typeset} typeset The Array typeset to check against. + * @param {Array} array The Array {@link rtvref.types.typeset typeset} to check + * against. * @returns {(rtvref.RtvSuccess|rtvref.RtvError)} Success indicator if the `value` * is compliant to the `typeset`; error indicator otherwise. An exception is * __not__ thrown if the `value` is non-compliant. * @throws {Error} If `typeset` is not a valid Array typeset. */ // @param {rtvref.impl._checkOptions} [options] (internal parameter) -const checkWithArray = function(value, typeset /*, options*/) { +const checkWithArray = function(value, array /*, options*/) { const options = _getCheckOptions(arguments.length > 2 ? arguments[2] : undefined); // check for an array first since that's must faster than isTypeset() - if (!isArray(typeset) || !(options.isTypeset || isTypeset(typeset))) { - throw new Error(`Invalid Array typeset=${print(typeset)}`); + if (!isArray(array) || !(options.isTypeset || isTypeset(array))) { + throw new Error(`Invalid typeset in array=${print(array)}`); } options.isTypeset = true; let match; // @type {(rtvref.types.fully_qualified_typeset|undefined)} - const qualifier = options.qualifier || getQualifier(typeset); + const qualifier = options.qualifier || getQualifier(array); // consider each type in the typeset until we find one that matches the value // NOTE: an Array typeset represents multiple possibilities for a type match @@ -574,18 +575,18 @@ const checkWithArray = function(value, typeset /*, options*/) { // NOTE: due to the isTypeset check above, we can assume that each 'type' is // a SHALLOW-valid typeset (meaning, if it's an Array typeset, we cannot // assume that itself is valid because the isTypeset check was just shallow) - const typesetCopy = typeset.concat(); // shallow clone so we can modify the array locally + const typesetCopy = array.concat(); // shallow clone so we can modify the array locally let subtype = extractNextType(typesetCopy, false); // exclude qualifier we already have while (subtype.length > 0) { // check for the validator, which will always come alone, and since the validator // must be at the end of an Array typeset, it also signals the end of all subtypes - if (subtype.length === 1 && isValidator(subtype[0])) { + if (subtype.length === 1 && isCustomValidator(subtype[0])) { // if we reach the validator (which must be the very last element) in this // loop, none of the types matched, unless the validator is the only // type in the typeset, at which point it gets an implied type of ANY, // which matches any value // NOTE: we have to test the original typeset for the ANY condition - if (typeset.length === 1 || (typeset.length === 2 && qualifiers.check(typeset[0]))) { + if (array.length === 1 || (array.length === 2 && qualifiers.check(array[0]))) { match = fullyQualify(types.ANY, qualifier); } @@ -611,19 +612,19 @@ const checkWithArray = function(value, typeset /*, options*/) { if (match) { // check for a validator at the end of the Array typeset and invoke it - const lastType = typeset[typeset.length - 1]; - if (isValidator(lastType)) { + const lastType = array[array.length - 1]; + if (isCustomValidator(lastType)) { try { - lastType(value, match, typeset); + lastType(value, match, array); } catch (cvErr) { // invalid in spite of the match since the validator said no - err = new RtvError(value, typeset, options.path, fullyQualify(typeset, qualifier), cvErr); + err = new RtvError(value, array, options.path, fullyQualify(array, qualifier), cvErr); } } // else, valid, since we have a match } else { // no match - err = new RtvError(value, typeset, options.path, fullyQualify(typeset, qualifier)); + err = new RtvError(value, array, options.path, fullyQualify(array, qualifier)); } return err || (new RtvSuccess()); @@ -652,7 +653,7 @@ const check = function(value, typeset /*, options*/) { return checkWithType(value, typeset, options); } - if (isValidator(typeset)) { + if (isCustomValidator(typeset)) { // custom validator: bare function implies the ANY type const match = types.ANY; const fqMatch = fullyQualify(match, options.qualifier); diff --git a/src/lib/lib.jsdoc b/src/lib/lib.jsdoc new file mode 100644 index 0000000..3877b98 --- /dev/null +++ b/src/lib/lib.jsdoc @@ -0,0 +1,8 @@ +/** + *

RTV.js Reference

+ * + * Members herein are _indirectly_ accessed and/or exposed through the + * {@link rtv RTV.js Public Interface}. + * + * @namespace rtvref + */ diff --git a/src/lib/qualifiers.js b/src/lib/qualifiers.js index 982848a..0425d1b 100644 --- a/src/lib/qualifiers.js +++ b/src/lib/qualifiers.js @@ -3,7 +3,7 @@ import Enumeration from './Enumeration'; /** - *

Qualifiers

+ *

Qualifiers

* * Qualifiers determine the degree at which a value must be of a given type. * @@ -93,7 +93,7 @@ export const DEFAULT_QUALIFIER = REQUIRED; * - EXPECTED: Can be `null`. * - OPTIONAL: Can be either `undefined` or `null`. * - * @function rtvref.qualifiers.checkBasicRules + * @function rtvref.qualifiers.nilPermitted * @param {*} v Value to check. * @param {string} [q] Validation qualifier. Defaults to * {@link rtvref.qualifiers.REQUIRED REQUIRED}. @@ -117,7 +117,12 @@ export const nilPermitted = function(v, q = REQUIRED) { }; /** - * Enumeration (`string -> string`) of {@link rtvref.qualifiers qualifiers}. + * Enumeration (`string -> string`) of all qualifiers: + * + * - {@link rtvref.qualifiers.REQUIRED REQUIRED} + * - {@link rtvref.qualifiers.EXPECTED EXPECTED} + * - {@link rtvref.qualifiers.OPTIONAL OPTIONAL} + * * @name rtvref.qualifiers.qualifiers * @type {rtvref.Enumeration} */ diff --git a/src/lib/types.js b/src/lib/types.js index 1a9e8a7..09d0273 100644 --- a/src/lib/types.js +++ b/src/lib/types.js @@ -3,7 +3,7 @@ import Enumeration from './Enumeration'; /** - *

Types

+ *

Types

* @namespace rtvref.types */ @@ -23,7 +23,7 @@ import Enumeration from './Enumeration'; * it produces an {@link rtvref.types.OBJECT object}, and __should be avoided__). * - `Symbol` * - * @typedef {*} rtvref.types.primitives + * @typedef {void} rtvref.types.primitives * @see {@link rtvref.validation.isPrimitive} */ @@ -39,7 +39,7 @@ import Enumeration from './Enumeration'; * the qualifier used is `EXPECTED`; and it could be `undefined` if the qualifier * used is `OPTIONAL`. * - * @typedef {*} rtvref.types.rules + * @typedef {void} rtvref.types.qualifier_rules */ /** @@ -85,7 +85,7 @@ import Enumeration from './Enumeration'; * of at least 5 characters in length. * * Since {@link rtvref.qualifiers qualifiers} may affect how a value is validated - * against a type, {@link rtvref.types.rules qualifier rules} always take + * against a type, {@link rtvref.types.qualifier_rules qualifier rules} always take * __precedence__ over any argument specified. For example, `[STRING, {min: 0}]` * would fail to validate an empty string because the _implied_ qualifier * is `REQUIRED`, and per {@link rtvref.types.STRING STRING} qualifier rules, @@ -386,7 +386,7 @@ import Enumeration from './Enumeration'; * over network requests, perhaps embedded in JSON payloads, similar to * {@link https://json-ld.org/ JSON-LD} schemas. * - *

Example: Object

+ *

Typeset Example: Object

* *
const contactShape = {
  *   name: rtv.t.STRING, // required, non-empty, string
@@ -429,20 +429,20 @@ import Enumeration from './Enumeration';
  * }, walletShape); // OK
  * 
* - *

Example: String

+ *

Typeset Example: String

* *
rtv.verify('foo', rtv.t.STRING); // OK
  * rtv.verify('foo', rtv.t.FINITE); // ERROR
  * 
* - *

Example: Array

+ *

Typeset Example: Array

* *
const typeset = [rtv.t.STRING, rtv.t.FINITE]; // non-empty string, or finite number
  * rtv.verify('foo', typeset); // OK
  * rtv.verify(1, typeset); // OK
  * 
* - *

Example: Function

+ *

Typeset Example: Function

* *
const validator = (v) => {
  *   if (v % 10) {
@@ -454,7 +454,7 @@ import Enumeration from './Enumeration';
  * rtv.verify(120, [rtv.t.INT, validator]); // OK
  * 
* - *

Example: Alternate Qualifier

+ *

Typeset Example: Alternate Qualifier

* *
const person = {
  *   name: rtv.t.STRING, // required, non-empty
@@ -544,7 +544,7 @@ import Enumeration from './Enumeration';
  *  {@link rtvref.RtvError#failure failure} property, as well as part of its
  *  `message`. Therefore, it's recommended to throw an error with a message that
  *  will help the developer determine why the custom validation failed.
- * @see {@link rtvref.validation.isValidator}
+ * @see {@link rtvref.validation.isCustomValidator}
  */
 
 // Creates a definition object.
@@ -713,7 +713,7 @@ const defs = {
    *
    * Arguments (optional): {@link rtvref.types.numeric_args}
    *
-   * @name rtvref.types.INT
+   * @name rtvref.types.SAFE_INT
    * @const {string}
    * @see {@link rtvref.qualifiers}
    * @see {@link rtvref.types.NUMBER}
@@ -809,7 +809,7 @@ const defs = {
    *  They represent a set of types that will be used to validate each element
    *  of an array using a short-circuit OR conjunction, looking for the first type that matches.
    *
-   * 

Example: Simple array

+ *

Array Example: Simple array

* * The `value` property must be an array (possibly empty) of any type of value. * @@ -824,7 +824,7 @@ const defs = { * to indicate what could be the equivalent: `[[]]`. The inner Array typeset * would be deemed _invalid_. * - *

Example: Shorthand notation

+ *

Array Example: Shorthand notation

* * The `value` property must be an array (possibly empty) of finite numbers of * any value. @@ -834,7 +834,7 @@ const defs = { * } *
* - *

Example: Shorthand, mixed types

+ *

Array Example: Shorthand, mixed types

* * The `value` property must be either a boolean; or an array (possibly empty) of * finite numbers of any value, or non-empty strings, or a mix of both. @@ -844,7 +844,7 @@ const defs = { * } * * - *

Example: Fully-qualified notation, no typeset

+ *

Array Example: Fully-qualified notation, no typeset

* * The `value` property must be a non-empty array of any type of value. * @@ -853,7 +853,7 @@ const defs = { * } * * - *

Example: Fully-qualified notation

+ *

Array Example: Fully-qualified notation

* * The `value` property must be an array (possibly empty) of finite numbers of * any value (nested typeset is not fully-qualified). @@ -863,7 +863,7 @@ const defs = { * } * * - *

Example: Fully-qualified, mixed types

+ *

Array Example: Fully-qualified, mixed types

* * The `value` property must be either a boolean; or an array (possibly empty) of * finite numbers of any value, or non-empty strings, or a mix of both @@ -1210,9 +1210,13 @@ const defs = { export const DEFAULT_OBJECT_TYPE = defs.OBJECT.value; /** - * Enumeration (`string -> string`) of __object__ {@link rtvref.types types}. These - * are all the types that describe values which are essentially maps of various - * keys to values. + * Enumeration (`string -> string`) of __object__ types: + * + * - {@link rtvref.types.ANY_OBJECT ANY_OBJECT} + * - {@link rtvref.types.OBJECT OBJECT} + * - {@link rtvref.types.PLAIN_OBJECT PLAIN_OBJECT} + * - {@link rtvref.types.CLASS_OBJECT CLASS_OBJECT} + * * @name rtvref.types.objTypes * @type {rtvref.Enumeration} */ @@ -1227,8 +1231,24 @@ export const objTypes = new Enumeration(function() { }(), 'objTypes'); /** - * Enumeration (`string -> string`) of {@link rtvref.types types} that accept - * arguments. + * Enumeration (`string -> string`) of types that accept arguments: + * + * - {@link rtvref.types.STRING STRING} + * - {@link rtvref.types.SYMBOL SYMBOL} + * - {@link rtvref.types.NUMBER NUMBER} + * - {@link rtvref.types.FINITE FINITE} + * - {@link rtvref.types.INT INT} + * - {@link rtvref.types.SAFE_INT SAFE_INT} + * - {@link rtvref.types.FLOAT FLOAT} + * - {@link rtvref.types.ARRAY ARRAY} + * - {@link rtvref.types.ANY_OBJECT ANY_OBJECT} + * - {@link rtvref.types.OBJECT OBJECT} + * - {@link rtvref.types.PLAIN_OBJECT PLAIN_OBJECT} + * - {@link rtvref.types.CLASS_OBJECT CLASS_OBJECT} + * - {@link rtvref.types.HASH_MAP HASH_MAP} + * - {@link rtvref.types.MAP MAP} + * - {@link rtvref.types.SET SET} + * * @name rtvref.types.argTypes * @type {rtvref.Enumeration} */ @@ -1243,7 +1263,35 @@ export const argTypes = new Enumeration(function() { }(), 'argTypes'); /** - * Enumeration (`string -> string`) of all {@link rtvref.types types}. + * Enumeration (`string -> string`) of all types: + * + * - {@link rtvref.types.ANY ANY} + * - {@link rtvref.types.NULL NULL} + * - {@link rtvref.types.STRING STRING} + * - {@link rtvref.types.BOOLEAN BOOLEAN} + * - {@link rtvref.types.SYMBOL SYMBOL} + * - {@link rtvref.types.NUMBER NUMBER} + * - {@link rtvref.types.FINITE FINITE} + * - {@link rtvref.types.INT INT} + * - {@link rtvref.types.SAFE_INT SAFE_INT} + * - {@link rtvref.types.FLOAT FLOAT} + * - {@link rtvref.types.FUNCTION FUNCTION} + * - {@link rtvref.types.REGEXP REGEXP} + * - {@link rtvref.types.DATE DATE} + * - {@link rtvref.types.ERROR ERROR} + * - {@link rtvref.types.PROMISE PROMISE} + * - {@link rtvref.types.ARRAY ARRAY} + * - {@link rtvref.types.ANY_OBJECT ANY_OBJECT} + * - {@link rtvref.types.OBJECT OBJECT} + * - {@link rtvref.types.PLAIN_OBJECT PLAIN_OBJECT} + * - {@link rtvref.types.CLASS_OBJECT CLASS_OBJECT} + * - {@link rtvref.types.HASH_MAP HASH_MAP} + * - {@link rtvref.types.MAP MAP} + * - {@link rtvref.types.WEAK_MAP WEAK_MAP} + * - {@link rtvref.types.SET SET} + * - {@link rtvref.types.WEAK_SET WEAK_SET} + * - {@link rtvref.types.JSON JSON} + * * @name rtvref.types.types * @type {rtvref.Enumeration} */ diff --git a/src/lib/util.js b/src/lib/util.js index 42635b5..b5691b2 100644 --- a/src/lib/util.js +++ b/src/lib/util.js @@ -5,14 +5,13 @@ // this library. /** - * RTV Utilities Module - * @private - * @namespace rtv.util + *

RTV.js Utilities

+ * @namespace rtvref.util */ /** * Pretty-print a value. - * @function rtv.util.print + * @function rtvref.util.print * @param {*} printValue Value to print. * @returns {string} Pretty-printed value. It's not perfect and may not catch * all types, but attempts to be good enough. diff --git a/src/lib/validation/isAny.js b/src/lib/validation/isAny.js index 405ad5f..04e8890 100644 --- a/src/lib/validation/isAny.js +++ b/src/lib/validation/isAny.js @@ -2,6 +2,11 @@ import types from '../types'; +/** + * Validation Module: isAny + * @typedef {Module} rtvref.validation.isAny + */ + /** * Type: {@link rtvref.types.ANY ANY} * @const {string} rtvref.validation.isAny.type diff --git a/src/lib/validation/isAnyObject.js b/src/lib/validation/isAnyObject.js index 86ded1e..d462d91 100644 --- a/src/lib/validation/isAnyObject.js +++ b/src/lib/validation/isAnyObject.js @@ -4,6 +4,11 @@ import {default as _isObject} from 'lodash/isObject'; import types from '../types'; +/** + * Validation Module: isAnyObject + * @typedef {Module} rtvref.validation.isAnyObject + */ + /** * Type: {@link rtvref.types.ANY_OBJECT ANY_OBJECT} * @const {string} rtvref.validation.isAnyObject.type diff --git a/src/lib/validation/isArray.js b/src/lib/validation/isArray.js index 20753a6..9c5f959 100644 --- a/src/lib/validation/isArray.js +++ b/src/lib/validation/isArray.js @@ -4,6 +4,11 @@ import {default as _isArray} from 'lodash/isArray'; import types from '../types'; +/** + * Validation Module: isArray + * @typedef {Module} rtvref.validation.isArray + */ + /** * Type: {@link rtvref.types.ARRAY ARRAY} * @const {string} rtvref.validation.isArray.type diff --git a/src/lib/validation/isBoolean.js b/src/lib/validation/isBoolean.js index 220cf3e..45af7f4 100644 --- a/src/lib/validation/isBoolean.js +++ b/src/lib/validation/isBoolean.js @@ -2,6 +2,11 @@ import types from '../types'; +/** + * Validation Module: isBoolean + * @typedef {Module} rtvref.validation.isBoolean + */ + /** * Type: {@link rtvref.types.BOOLEAN BOOLEAN} * @const {string} rtvref.validation.isBoolean.type diff --git a/src/lib/validation/isClassObject.js b/src/lib/validation/isClassObject.js index 92957ea..918b64b 100644 --- a/src/lib/validation/isClassObject.js +++ b/src/lib/validation/isClassObject.js @@ -5,6 +5,11 @@ import isPlainObject from './isPlainObject'; import types from '../types'; +/** + * Validation Module: isClassObject + * @typedef {Module} rtvref.validation.isClassObject + */ + /** * Type: {@link rtvref.types.CLASS_OBJECT CLASS_OBJECT} * @const {string} rtvref.validation.isClassObject.type diff --git a/src/lib/validation/isValidator.js b/src/lib/validation/isCustomValidator.js similarity index 52% rename from src/lib/validation/isValidator.js rename to src/lib/validation/isCustomValidator.js index a30c974..a8a6658 100644 --- a/src/lib/validation/isValidator.js +++ b/src/lib/validation/isCustomValidator.js @@ -1,21 +1,24 @@ -////// isValidator validation module +////// isCustomValidator validation module import isFunction from './isFunction'; +/** + * Validation Module: isCustomValidator + * @typedef {Module} rtvref.validation.isCustomValidator + */ + /** * Type: `undefined`, {@link rtvref.types.custom_validator custom validator} pseudo-type. - * @const {string} rtvref.validation.isValidator.type + * @const {string} rtvref.validation.isCustomValidator.type */ export const type = undefined; /** * Determines if a value is a {@link rtvref.types.custom_validator custom validator}. - * @function rtvref.validation.isValidator.default + * @function rtvref.validation.isCustomValidator.default * @param {*} v Value to validate. * @returns {boolean} `true` if it is; `false` otherwise. */ -export default function isValidator(v) { - // TODO[plugins]: should this module be renamed to isCustomValidator since it's - // perhaps overloaded with 'validator' concept for plugins @see rtvref.validator? +export default function isCustomValidator(v) { return isFunction(v); } diff --git a/src/lib/validation/isDate.js b/src/lib/validation/isDate.js index d95a5c6..36c2caf 100644 --- a/src/lib/validation/isDate.js +++ b/src/lib/validation/isDate.js @@ -4,6 +4,11 @@ import {default as _isDate} from 'lodash/isDate'; import types from '../types'; +/** + * Validation Module: isDate + * @typedef {Module} rtvref.validation.isDate + */ + /** * Type: {@link rtvref.types.DATE DATE} * @const {string} rtvref.validation.isDate.type diff --git a/src/lib/validation/isError.js b/src/lib/validation/isError.js index f3f24f8..498bdfd 100644 --- a/src/lib/validation/isError.js +++ b/src/lib/validation/isError.js @@ -4,6 +4,11 @@ import {default as _isError} from 'lodash/isError'; import types from '../types'; +/** + * Validation Module: isError + * @typedef {Module} rtvref.validation.isError + */ + /** * Type: {@link rtvref.types.ERROR ERROR} * @const {string} rtvref.validation.isError.type diff --git a/src/lib/validation/isFinite.js b/src/lib/validation/isFinite.js index 7e7a325..019a8f0 100644 --- a/src/lib/validation/isFinite.js +++ b/src/lib/validation/isFinite.js @@ -4,6 +4,11 @@ import {default as _isFinite} from 'lodash/isFinite'; import types from '../types'; +/** + * Validation Module: isFinite + * @typedef {Module} rtvref.validation.isFinite + */ + /** * Type: {@link rtvref.types.FINITE FINITE} * @const {string} rtvref.validation.isFinite.type diff --git a/src/lib/validation/isFloat.js b/src/lib/validation/isFloat.js index 121931a..9e510c1 100644 --- a/src/lib/validation/isFloat.js +++ b/src/lib/validation/isFloat.js @@ -5,6 +5,11 @@ import isInt from './isInt'; import types from '../types'; +/** + * Validation Module: isFloat + * @typedef {Module} rtvref.validation.isFloat + */ + /** * Type: {@link rtvref.types.FLOAT FLOAT} * @const {string} rtvref.validation.isFloat.type diff --git a/src/lib/validation/isFunction.js b/src/lib/validation/isFunction.js index b2231e6..debc443 100644 --- a/src/lib/validation/isFunction.js +++ b/src/lib/validation/isFunction.js @@ -4,6 +4,11 @@ import {default as _isFunction} from 'lodash/isFunction'; import types from '../types'; +/** + * Validation Module: isFunction + * @typedef {Module} rtvref.validation.isFunction + */ + /** * Type: {@link rtvref.types.FUNCTION FUNCTION} * @const {string} rtvref.validation.isFunction.type diff --git a/src/lib/validation/isHashMap.js b/src/lib/validation/isHashMap.js index 1a9b975..48eb97f 100644 --- a/src/lib/validation/isHashMap.js +++ b/src/lib/validation/isHashMap.js @@ -4,6 +4,11 @@ import isObject from './isObject'; import types from '../types'; +/** + * Validation Module: isHashMap + * @typedef {Module} rtvref.validation.isHashMap + */ + /** * Type: {@link rtvref.types.HASH_MAP HASH_MAP} * @const {string} rtvref.validation.isHashMap.type diff --git a/src/lib/validation/isInt.js b/src/lib/validation/isInt.js index c6f4af2..e053670 100644 --- a/src/lib/validation/isInt.js +++ b/src/lib/validation/isInt.js @@ -4,6 +4,11 @@ import {default as _isInteger} from 'lodash/isInteger'; import types from '../types'; +/** + * Validation Module: isInt + * @typedef {Module} rtvref.validation.isInt + */ + /** * Type: {@link rtvref.types.INT INT} * @const {string} rtvref.validation.isInt.type diff --git a/src/lib/validation/isJson.js b/src/lib/validation/isJson.js index 3b5bb2f..69a9aa8 100644 --- a/src/lib/validation/isJson.js +++ b/src/lib/validation/isJson.js @@ -9,6 +9,11 @@ import isArray from './isArray'; import types from '../types'; +/** + * Validation Module: isJson + * @typedef {Module} rtvref.validation.isJson + */ + /** * Type: {@link rtvref.types.JSON JSON} * @const {string} rtvref.validation.isJson.type diff --git a/src/lib/validation/isMap.js b/src/lib/validation/isMap.js index 3781df7..1cbaa89 100644 --- a/src/lib/validation/isMap.js +++ b/src/lib/validation/isMap.js @@ -4,6 +4,11 @@ import {default as _isMap} from 'lodash/isMap'; import types from '../types'; +/** + * Validation Module: isMap + * @typedef {Module} rtvref.validation.isMap + */ + /** * Type: {@link rtvref.types.MAP MAP} * @const {string} rtvref.validation.isMap.type diff --git a/src/lib/validation/isNull.js b/src/lib/validation/isNull.js index 32f697e..9fb54ce 100644 --- a/src/lib/validation/isNull.js +++ b/src/lib/validation/isNull.js @@ -2,9 +2,14 @@ import types from '../types'; +/** + * Validation Module: isNull + * @typedef {Module} rtvref.validation.isNull + */ + /** * Type: {@link rtvref.types.NULL NULL} - * @const {string} rtvref.validation.isFunction.type + * @const {string} rtvref.validation.isNull.type */ export const type = types.NULL; diff --git a/src/lib/validation/isNumber.js b/src/lib/validation/isNumber.js index d2efe1d..492b0a2 100644 --- a/src/lib/validation/isNumber.js +++ b/src/lib/validation/isNumber.js @@ -4,6 +4,11 @@ import {default as _isNaN} from 'lodash/isNaN'; import types from '../types'; +/** + * Validation Module: isNumber + * @typedef {Module} rtvref.validation.isNumber + */ + /** * Type: {@link rtvref.types.NUMBER NUMBER} * @const {string} rtvref.validation.isNumber.type diff --git a/src/lib/validation/isObject.js b/src/lib/validation/isObject.js index 9f0b58c..efd6ab3 100644 --- a/src/lib/validation/isObject.js +++ b/src/lib/validation/isObject.js @@ -14,6 +14,11 @@ import isPromise from './isPromise'; import types from '../types'; +/** + * Validation Module: isObject + * @typedef {Module} rtvref.validation.isObject + */ + /** * Type: {@link rtvref.types.OBJECT OBJECT} * @const {string} rtvref.validation.isObject.type diff --git a/src/lib/validation/isPlainObject.js b/src/lib/validation/isPlainObject.js index bf80819..112bcd5 100644 --- a/src/lib/validation/isPlainObject.js +++ b/src/lib/validation/isPlainObject.js @@ -4,6 +4,11 @@ import {default as _isPlainObject} from 'lodash/isPlainObject'; import types from '../types'; +/** + * Validation Module: isPlainObject + * @typedef {Module} rtvref.validation.isPlainObject + */ + /** * Type: {@link rtvref.types.PLAIN_OBJECT PLAIN_OBJECT} * @const {string} rtvref.validation.isPlainObject.type diff --git a/src/lib/validation/isPrimitive.js b/src/lib/validation/isPrimitive.js index 3950f69..68889d5 100644 --- a/src/lib/validation/isPrimitive.js +++ b/src/lib/validation/isPrimitive.js @@ -5,6 +5,11 @@ import isBoolean from './isBoolean'; import isNumber from './isNumber'; import isSymbol from './isSymbol'; +/** + * Validation Module: isPrimitive + * @typedef {Module} rtvref.validation.isPrimitive + */ + /** * Type: `undefined`, {@link rtvref.types.primitives primitive} pseudo-type. * @const {string} rtvref.validation.isPrimitive.type diff --git a/src/lib/validation/isPromise.js b/src/lib/validation/isPromise.js index 2ec8269..c8305a3 100644 --- a/src/lib/validation/isPromise.js +++ b/src/lib/validation/isPromise.js @@ -2,6 +2,11 @@ import types from '../types'; +/** + * Validation Module: isPromise + * @typedef {Module} rtvref.validation.isPromise + */ + /** * Type: {@link rtvref.types.PROMISE PROMISE} * @const {string} rtvref.validation.isPromise.type diff --git a/src/lib/validation/isRegExp.js b/src/lib/validation/isRegExp.js index cbfd463..4c5ef87 100644 --- a/src/lib/validation/isRegExp.js +++ b/src/lib/validation/isRegExp.js @@ -4,6 +4,11 @@ import {default as _isRegExp} from 'lodash/isRegExp'; import types from '../types'; +/** + * Validation Module: isRegExp + * @typedef {Module} rtvref.validation.isRegExp + */ + /** * Type: {@link rtvref.types.REGEXP REGEXP} * @const {string} rtvref.validation.isRegExp.type diff --git a/src/lib/validation/isSafeInt.js b/src/lib/validation/isSafeInt.js index dcf87f0..228bc8e 100644 --- a/src/lib/validation/isSafeInt.js +++ b/src/lib/validation/isSafeInt.js @@ -4,6 +4,11 @@ import {default as _isSafeInteger} from 'lodash/isSafeInteger'; import types from '../types'; +/** + * Validation Module: isSafeInt + * @typedef {Module} rtvref.validation.isSafeInt + */ + /** * Type: {@link rtvref.types.SAFE_INT SAFE_INT} * @const {string} rtvref.validation.isSafeInt.type diff --git a/src/lib/validation/isSet.js b/src/lib/validation/isSet.js index 64648f2..cbcc4c4 100644 --- a/src/lib/validation/isSet.js +++ b/src/lib/validation/isSet.js @@ -4,6 +4,11 @@ import {default as _isSet} from 'lodash/isSet'; import types from '../types'; +/** + * Validation Module: isSet + * @typedef {Module} rtvref.validation.isSet + */ + /** * Type: {@link rtvref.types.SET SET} * @const {string} rtvref.validation.isSet.type diff --git a/src/lib/validation/isShape.js b/src/lib/validation/isShape.js index 9e36370..1a50bdc 100644 --- a/src/lib/validation/isShape.js +++ b/src/lib/validation/isShape.js @@ -2,6 +2,11 @@ import isObject from './isObject'; +/** + * Validation Module: isShape + * @typedef {Module} rtvref.validation.isShape + */ + /** * Type: `undefined`, {@link rtvref.types.shape_descriptor shape} pseudo-type. * @const {string} rtvref.validation.isShape.type diff --git a/src/lib/validation/isString.js b/src/lib/validation/isString.js index 6caf90a..6a29d4b 100644 --- a/src/lib/validation/isString.js +++ b/src/lib/validation/isString.js @@ -2,6 +2,11 @@ import types from '../types'; +/** + * Validation Module: isString + * @typedef {Module} rtvref.validation.isString + */ + /** * Type: {@link rtvref.types.STRING STRING} * @const {string} rtvref.validation.isString.type diff --git a/src/lib/validation/isSymbol.js b/src/lib/validation/isSymbol.js index 7058601..930db74 100644 --- a/src/lib/validation/isSymbol.js +++ b/src/lib/validation/isSymbol.js @@ -4,6 +4,11 @@ import {default as _isSymbol} from 'lodash/isSymbol'; import types from '../types'; +/** + * Validation Module: isSymbol + * @typedef {Module} rtvref.validation.isSymbol + */ + /** * Type: {@link rtvref.types.SYMBOL SYMBOL} * @const {string} rtvref.validation.isSymbol.type diff --git a/src/lib/validation/isTypeArgs.js b/src/lib/validation/isTypeArgs.js index 6b6290f..8b2c55e 100644 --- a/src/lib/validation/isTypeArgs.js +++ b/src/lib/validation/isTypeArgs.js @@ -2,6 +2,11 @@ import isObject from './isObject'; +/** + * Validation Module: isTypeArgs + * @typedef {Module} rtvref.validation.isTypeArgs + */ + /** * Type: `undefined`, {@link rtvref.types.type_arguments type arguments} pseudo-type. * @const {string} rtvref.validation.isTypeArgs.type diff --git a/src/lib/validation/isTypeset.js b/src/lib/validation/isTypeset.js index 9aeeadd..6de952d 100644 --- a/src/lib/validation/isTypeset.js +++ b/src/lib/validation/isTypeset.js @@ -6,7 +6,7 @@ import isArray from './isArray'; import isShape from './isShape'; import isTypeArgs from './isTypeArgs'; import isString from './isString'; -import isValidator from './isValidator'; +import isCustomValidator from './isCustomValidator'; import {default as types, argTypes, objTypes, DEFAULT_OBJECT_TYPE} from '../types'; import qualifiers from '../qualifiers'; @@ -62,6 +62,11 @@ const deepVerifyArray = function(typeset, options, failurePrefix, idx) { return valid; }; +/** + * Validation Module: isTypeset + * @typedef {Module} rtvref.validation.isTypeset + */ + /** * Type: `undefined`, {@link rtvref.types.typeset typeset} pseudo-type. * @const {string} rtvref.validation.isTypeset.type @@ -89,7 +94,7 @@ export default function isTypeset(v, options = {deep: false, fullyQualified: fal // FIRST: make sure it's an acceptable type for a typeset: shape, string // (just a plain type name), function (validator), or array (non-empty) - let valid = !!(v && (isShape(v) || (isString(v) && types.check(v)) || isValidator(v) || + let valid = !!(v && (isShape(v) || (isString(v) && types.check(v)) || isCustomValidator(v) || (isArray(v) && v.length > 0))); if (!valid) { @@ -155,7 +160,7 @@ export default function isTypeset(v, options = {deep: false, fullyQualified: fal // have to ensure that args were given when we change the type) argType = argTypes.check(rule); } - } else if (isValidator(rule)) { + } else if (isCustomValidator(rule)) { // must be a validator, but there can't be more than 1, it must be // in the last position (which enforces the 1 count), always after the // qualifier, and since the typeset must be FQ'd, we must have an @@ -256,7 +261,7 @@ export default function isTypeset(v, options = {deep: false, fullyQualified: fal valid = false; options.failure = `${failurePrefix}: Unknown/invalid qualifier/type=${print(rule)} at index=${idx}`; } - } else if (isValidator(rule)) { + } else if (isCustomValidator(rule)) { // must be a validator, but there can't be more than 1, and it must be // in the last position (which enforces the 1 count), and always after // the qualifier (if any) diff --git a/src/lib/validation/isWeakMap.js b/src/lib/validation/isWeakMap.js index c3f4273..03d0e37 100644 --- a/src/lib/validation/isWeakMap.js +++ b/src/lib/validation/isWeakMap.js @@ -4,6 +4,11 @@ import {default as _isWeakMap} from 'lodash/isWeakMap'; import types from '../types'; +/** + * Validation Module: isWeakMap + * @typedef {Module} rtvref.validation.isWeakMap + */ + /** * Type: {@link rtvref.types.WEAK_MAP WEAK_MAP} * @const {string} rtvref.validation.isWeakMap.type diff --git a/src/lib/validation/isWeakSet.js b/src/lib/validation/isWeakSet.js index d56dca5..9706b10 100644 --- a/src/lib/validation/isWeakSet.js +++ b/src/lib/validation/isWeakSet.js @@ -4,6 +4,11 @@ import {default as _isWeakSet} from 'lodash/isWeakSet'; import types from '../types'; +/** + * Validation Module: isWeakSet + * @typedef {Module} rtvref.validation.isWeakSet + */ + /** * Type: {@link rtvref.types.WEAK_SET WEAK_SET} * @const {string} rtvref.validation.isWeakSet.type diff --git a/src/lib/validation/validation.jsdoc b/src/lib/validation/validation.jsdoc index edc6d30..8c059fe 100644 --- a/src/lib/validation/validation.jsdoc +++ b/src/lib/validation/validation.jsdoc @@ -1,7 +1,7 @@ ////// Validation Module /** - *

RTV Validation

+ *

RTV.js Validation

* * This namespace provides _type validations_ which verify values to be of * the {@link rtvref.types types} defined in this library. If permitted values diff --git a/src/lib/validator/valAny.js b/src/lib/validator/valAny.js index 0eaeb86..596a64a 100644 --- a/src/lib/validator/valAny.js +++ b/src/lib/validator/valAny.js @@ -6,6 +6,11 @@ import qualifiers from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valAny + * @typedef {Module} rtvref.validator.valAny + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -26,7 +31,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valAny.config + * @function rtvref.validator.valAny.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valAnyObject.js b/src/lib/validator/valAnyObject.js index 97c3921..14860a9 100644 --- a/src/lib/validator/valAnyObject.js +++ b/src/lib/validator/valAnyObject.js @@ -9,6 +9,11 @@ import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; import isShape from '../validation/isShape'; +/** + * Validator Module: valAnyObject + * @typedef {Module} rtvref.validator.valAnyObject + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -29,7 +34,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valAnyObject.config + * @function rtvref.validator.valAnyObject.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valArray.js b/src/lib/validator/valArray.js index fe7d139..5a46bf2 100644 --- a/src/lib/validator/valArray.js +++ b/src/lib/validator/valArray.js @@ -9,6 +9,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valArray + * @typedef {Module} rtvref.validator.valArray + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -29,7 +34,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valArray.config + * @function rtvref.validator.valArray.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valBoolean.js b/src/lib/validator/valBoolean.js index 9885cc2..bbcaae7 100644 --- a/src/lib/validator/valBoolean.js +++ b/src/lib/validator/valBoolean.js @@ -6,6 +6,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valBoolean + * @typedef {Module} rtvref.validator.valBoolean + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -26,7 +31,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valBoolean.config + * @function rtvref.validator.valBoolean.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valClassObject.js b/src/lib/validator/valClassObject.js index c54de10..4d858d3 100644 --- a/src/lib/validator/valClassObject.js +++ b/src/lib/validator/valClassObject.js @@ -10,6 +10,11 @@ import RtvError from '../RtvError'; import isShape from '../validation/isShape'; import isFunction from '../validation/isFunction'; +/** + * Validator Module: valClassObject + * @typedef {Module} rtvref.validator.valClassObject + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -30,7 +35,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valClassObject.config + * @function rtvref.validator.valClassObject.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valDate.js b/src/lib/validator/valDate.js index 78cb22d..8d56d7e 100644 --- a/src/lib/validator/valDate.js +++ b/src/lib/validator/valDate.js @@ -6,6 +6,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valDate + * @typedef {Module} rtvref.validator.valDate + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -26,7 +31,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valDate.config + * @function rtvref.validator.valDate.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valError.js b/src/lib/validator/valError.js index 09836f4..9278f9e 100644 --- a/src/lib/validator/valError.js +++ b/src/lib/validator/valError.js @@ -6,6 +6,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valError + * @typedef {Module} rtvref.validator.valError + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -26,7 +31,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valError.config + * @function rtvref.validator.valError.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valFinite.js b/src/lib/validator/valFinite.js index 53442a0..b50b1c7 100644 --- a/src/lib/validator/valFinite.js +++ b/src/lib/validator/valFinite.js @@ -8,6 +8,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valFinite + * @typedef {Module} rtvref.validator.valFinite + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -28,7 +33,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valFinite.config + * @function rtvref.validator.valFinite.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valFloat.js b/src/lib/validator/valFloat.js index d0e209b..35fcf50 100644 --- a/src/lib/validator/valFloat.js +++ b/src/lib/validator/valFloat.js @@ -8,6 +8,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valFloat + * @typedef {Module} rtvref.validator.valFloat + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -28,7 +33,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valFloat.config + * @function rtvref.validator.valFloat.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valFunction.js b/src/lib/validator/valFunction.js index bb0e11a..96cade0 100644 --- a/src/lib/validator/valFunction.js +++ b/src/lib/validator/valFunction.js @@ -9,6 +9,11 @@ import RtvError from '../RtvError'; const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} +/** + * Validator Module: valFunction + * @typedef {Module} rtvref.validator.valFunction + */ + /** * Type: {@link rtvref.types.FUNCTION FUNCTION} * @const {string} rtvref.validator.valFunction.type @@ -17,7 +22,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valFunction.config + * @function rtvref.validator.valFunction.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valHashMap.js b/src/lib/validator/valHashMap.js index 8910ac8..96a240a 100644 --- a/src/lib/validator/valHashMap.js +++ b/src/lib/validator/valHashMap.js @@ -13,6 +13,11 @@ import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; import {print} from '../util'; +/** + * Validator Module: valHashMap + * @typedef {Module} rtvref.validator.valHashMap + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -33,7 +38,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valHashMap.config + * @function rtvref.validator.valHashMap.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valInt.js b/src/lib/validator/valInt.js index 13102ef..9a3bf86 100644 --- a/src/lib/validator/valInt.js +++ b/src/lib/validator/valInt.js @@ -8,6 +8,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valInt + * @typedef {Module} rtvref.validator.valInt + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -28,7 +33,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valInt.config + * @function rtvref.validator.valInt.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valJson.js b/src/lib/validator/valJson.js index dffdbb9..2802ffd 100644 --- a/src/lib/validator/valJson.js +++ b/src/lib/validator/valJson.js @@ -6,6 +6,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valJson + * @typedef {Module} rtvref.validator.valJson + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -26,7 +31,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valJson.config + * @function rtvref.validator.valJson.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valMap.js b/src/lib/validator/valMap.js index 8370d04..46467f1 100644 --- a/src/lib/validator/valMap.js +++ b/src/lib/validator/valMap.js @@ -12,6 +12,11 @@ import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; import {print} from '../util'; +/** + * Validator Module: valMap + * @typedef {Module} rtvref.validator.valMap + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -32,7 +37,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valMap.config + * @function rtvref.validator.valMap.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valNull.js b/src/lib/validator/valNull.js index e405f87..dd6ae2c 100644 --- a/src/lib/validator/valNull.js +++ b/src/lib/validator/valNull.js @@ -6,6 +6,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valNull + * @typedef {Module} rtvref.validator.valNull + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -26,7 +31,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valNull.config + * @function rtvref.validator.valNull.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valNumber.js b/src/lib/validator/valNumber.js index ca2a76d..876fa63 100644 --- a/src/lib/validator/valNumber.js +++ b/src/lib/validator/valNumber.js @@ -10,6 +10,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valNumber + * @typedef {Module} rtvref.validator.valNumber + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -30,7 +35,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valNumber.config + * @function rtvref.validator.valNumber.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valObject.js b/src/lib/validator/valObject.js index df5d2ec..110fac0 100644 --- a/src/lib/validator/valObject.js +++ b/src/lib/validator/valObject.js @@ -9,6 +9,11 @@ import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; import isShape from '../validation/isShape'; +/** + * Validator Module: valObject + * @typedef {Module} rtvref.validator.valObject + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -29,7 +34,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valObject.config + * @function rtvref.validator.valObject.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valPlainObject.js b/src/lib/validator/valPlainObject.js index 6d643a0..fd232d3 100644 --- a/src/lib/validator/valPlainObject.js +++ b/src/lib/validator/valPlainObject.js @@ -9,6 +9,11 @@ import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; import isShape from '../validation/isShape'; +/** + * Validator Module: valPlainObject + * @typedef {Module} rtvref.validator.valPlainObject + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -29,7 +34,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valPlainObject.config + * @function rtvref.validator.valPlainObject.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valPromise.js b/src/lib/validator/valPromise.js index a63f180..4c4e9b7 100644 --- a/src/lib/validator/valPromise.js +++ b/src/lib/validator/valPromise.js @@ -6,6 +6,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valPromise + * @typedef {Module} rtvref.validator.valPromise + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -26,7 +31,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valPromise.config + * @function rtvref.validator.valPromise.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valRegExp.js b/src/lib/validator/valRegExp.js index e577335..9ed2c6c 100644 --- a/src/lib/validator/valRegExp.js +++ b/src/lib/validator/valRegExp.js @@ -6,6 +6,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valRegExp + * @typedef {Module} rtvref.validator.valRegExp + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -26,7 +31,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valRegExp.config + * @function rtvref.validator.valRegExp.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valSafeInt.js b/src/lib/validator/valSafeInt.js index 98d3078..4f9f956 100644 --- a/src/lib/validator/valSafeInt.js +++ b/src/lib/validator/valSafeInt.js @@ -8,6 +8,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valSafeInt + * @typedef {Module} rtvref.validator.valSafeInt + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -28,7 +33,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valSafeInt.config + * @function rtvref.validator.valSafeInt.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valSet.js b/src/lib/validator/valSet.js index d1b567e..357022b 100644 --- a/src/lib/validator/valSet.js +++ b/src/lib/validator/valSet.js @@ -10,6 +10,11 @@ import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; import {print} from '../util'; +/** + * Validator Module: valSet + * @typedef {Module} rtvref.validator.valSet + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -30,7 +35,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valSet.config + * @function rtvref.validator.valSet.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valString.js b/src/lib/validator/valString.js index 51af8d7..867b9a7 100644 --- a/src/lib/validator/valString.js +++ b/src/lib/validator/valString.js @@ -9,6 +9,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valString + * @typedef {Module} rtvref.validator.valString + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -29,7 +34,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valString.config + * @function rtvref.validator.valString.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valSymbol.js b/src/lib/validator/valSymbol.js index 1414573..852073c 100644 --- a/src/lib/validator/valSymbol.js +++ b/src/lib/validator/valSymbol.js @@ -8,6 +8,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valSymbol + * @typedef {Module} rtvref.validator.valSymbol + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -28,7 +33,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valSymbol.config + * @function rtvref.validator.valSymbol.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valWeakMap.js b/src/lib/validator/valWeakMap.js index 094b5ab..f6df774 100644 --- a/src/lib/validator/valWeakMap.js +++ b/src/lib/validator/valWeakMap.js @@ -6,6 +6,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valWeakMap + * @typedef {Module} rtvref.validator.valWeakMap + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -26,7 +31,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valWeakMap.config + * @function rtvref.validator.valWeakMap.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/valWeakSet.js b/src/lib/validator/valWeakSet.js index 76f97bc..85a202b 100644 --- a/src/lib/validator/valWeakSet.js +++ b/src/lib/validator/valWeakSet.js @@ -6,6 +6,11 @@ import {default as qualifiers, nilPermitted} from '../qualifiers'; import RtvSuccess from '../RtvSuccess'; import RtvError from '../RtvError'; +/** + * Validator Module: valWeakSet + * @typedef {Module} rtvref.validator.valWeakSet + */ + const {REQUIRED} = qualifiers; let impl; // @type {rtvref.impl} @@ -26,7 +31,7 @@ export {type}; /** * {@link rtvref.validator.validator_config Configuration Function} - * @function rtvref.validator.valWeakSet.config + * @function rtvref.validator.valWeakSet.config * @param {rtvref.validator.validator_config_settings} settings Configuration settings. */ export const config = function(settings) { diff --git a/src/lib/validator/validator.jsdoc b/src/lib/validator/validator.jsdoc index 9ddcaf1..5b0e205 100644 --- a/src/lib/validator/validator.jsdoc +++ b/src/lib/validator/validator.jsdoc @@ -1,7 +1,7 @@ ////// Validator Module /** - *

RTV Type Validators

+ *

RTV.js Type Validators

* * This namespace provides validators for each supported {@link rtvref.types type}, * capable of fully validating a value against that type. Validators differ from @@ -42,8 +42,8 @@ *

Type Validator Function

* * NOTE: A validator must always give __precedence__ to - * {@link rtvref.types.rules qualifier rules} for the type it's validating, over - * any arguments specified. For example, + * {@link rtvref.types.qualifier_rules qualifier rules} for the type it's + * validating, over any arguments specified. For example, * * __NOTE:__ A validator must support all its qualifier rules, including proper * handling of `null` values when {@link rtvref.qualifiers.EXPECTED EXPECTED} @@ -66,6 +66,8 @@ * `RtvError` if not. */ +// TODO[plugins]: Plugins should also be given access to the types and qualifiers +// __modules__ which they don't have access to via impl. /** *

Type Validator Configuration Settings

* diff --git a/src/rtv.js b/src/rtv.js index f47c3ec..1ce2efb 100644 --- a/src/rtv.js +++ b/src/rtv.js @@ -36,40 +36,70 @@ import * as valSymbol from './lib/validator/valSymbol'; import * as valWeakMap from './lib/validator/valWeakMap'; import * as valWeakSet from './lib/validator/valWeakSet'; +// TODO[future]: Consider making 'rtv' a function object rather than a plain object. +// Invoking it as a function would call rtv.verify(), so rtv.verify(...) could be +// shortened to rtv(...), and `rtv.e && rtv.verify(...)` would be shortened to just +// `rtv.e && rtv(...)`. This could easily be done in the future, but is not easily +// undone, so best to see how people use it first, and if `rtv.verify()` really +// is too much typing or not. /** - *

RTV.js Reference

+ *

RTV.js Public Interface

* - * Members herein are _indirectly_ exposed through the {@link rtv} object. - * @namespace rtvref - */ - -/** - *

RTV.js

+ * Provides the externally-facing API. It wraps the + * {@link rtvref.impl implementation}, adding a bit of syntactic sugar, and + * adds the {@link rtv.config configuration} facilities. * - * Runtime Verification Library for browsers and Node.js. * @namespace rtv */ const rtv = { /** - * Enumeration of {@link rtvref.types types}. + * Enumeration of {@link rtvref.types.types types}. + * @readonly * @name rtv.t - * @type {rtvref.Enumeration.} + * @type {rtvref.Enumeration} */ - t: types, + get t() { + return types; + }, /** - * Enumeration of {@link rtvref.qualifiers qualifiers}. + * Enumeration of {@link rtvref.qualifiers.qualifiers qualifiers}. + * @readonly * @name rtv.q - * @type {rtvref.Enumeration.} + * @type {rtvref.Enumeration} */ - q: qualifiers, + get q() { + return qualifiers; + }, /** * Determines if a value is a typeset. * @function rtv.isTypeset - * @see {@link rtvref.validation.isTypeset.default} + * @see {@link rtvref.validation.isTypeset} + */ + get isTypeset() { + return isTypeset; + }, + + /** + * Shortcut proxy for reading {@link rtv.config.enabled}. + * @readonly + * @name rtv.e + * @type {boolean} */ - isTypeset, + get e() { + return this.config.enabled; + }, + + /** + * Library version. + * @readonly + * @name rtv.version + * @type {string} + */ + get version() { + return VERSION; + }, /** * Checks a value against a typeset for compliance. @@ -106,24 +136,6 @@ const rtv = { return new RtvSuccess(); }, - /** - * Shortcut proxy to {@link rtv.check}. - * @function rtv.c - * @param {*} value Value to check. - * @param {rtvref.types.typeset} typeset Expected shape of (or typeset describing) - * the `value`. A shape is a kind of typeset. Normally, this is a - * {@link rtvref.types.shape_descriptor shape descriptor}. - * @returns {(rtvref.RtvSuccess|rtvref.RtvError)} Success indicator if the - * `value` is compliant to the `shape`; `RtvError` if not. __Unlike - * {@link rtv.verify verify()}, an exception is not thrown__ if the - * `value` is non-compliant. - * @throws {Error} If `typeset` is not a valid typeset. - * @see {@link rtv.check} - */ - c(value, typeset) { - return this.check(value, typeset); - }, - /** * __Requires__ a value to be compliant to a shape. * @@ -158,22 +170,7 @@ const rtv = { }, /** - * Shortcut proxy to {@link rtv.verify}. - * @param {*} value Value to check. - * @param {rtvref.types.typeset} typeset Expected shape of (or typeset describing) - * the `value`. A shape is a kind of typeset. Normally, this is a - * {@link rtvref.types.shape_descriptor shape descriptor}. - * @returns {rtvref.RtvSuccess} Success indicator IIF the `value` is compliant - * to the `shape`. Otherwise, an {@link rtvref.RtvError RtvError} __is thrown__. - * @throws {RtvError} If the `value` is not compliant to the `shape`. - * @see {@link rtv.verify} - */ - v(value, typeset) { - return this.verify(value, typeset); - }, - - /** - * RTV Library Configuration + *

RTV.js Configuration

* @namespace rtv.config */ config: Object.defineProperties({}, { @@ -181,24 +178,54 @@ const rtv = { * Globally enables or disables {@link rtv.verify} and {@link rtv.check}. * * Use this, or the shortcut {@link rtv.e}, to enable code optimization - * when building source with a bundler that supports _tree shaking_ like + * when building source with a bundler that supports _tree shaking_, like * {@link https://rollupjs.org/ Rollup} or {@link https://webpack.js.org/ Webpack}. * - *

Example

+ * The following plugins can redefine the statement `rtv.e` or `rtv.config.enabled` + * as `false` prior to code optimizations that remove unreachable code: + * + * - Rollup: {@link https://github.com/rollup/rollup-plugin-replace rollup-plugin-replace} + * - Webpack: {@link https://webpack.js.org/plugins/define-plugin/ DefinePlugin} + * + *

Enabled Example: Rollup

* * By conditionally calling {@link rtv.verify} based on the state of * {@link rtv.config.enabled}, a bundler can be configured to completely * remove the code from a production build. * - * // TODO: Add Rollup and Webpack examples. + * Given this module code snippet: * - *
if (rtv.config.enabled) {
+     * 
...
+     *
+     * if (rtv.config.enabled) {
      *  rtv.verify(jsonResult, expectedShape);
      * }
      *
-     * rtv.e && rtv.v(jsonResult, expectedShape); // even shorter
+     * rtv.e && rtv.verify(jsonResult, expectedShape); // shorter
+     *
+     * ...
      * 
* + * And using this `rollup.config.js` snippet: + * + *
const replacePlugin = require('rollup-plugin-replace');
+     *
+     * module.exports = {
+     *   ...
+     *   plugins: [
+     *     // invoke this plugin _before_ any other plugins
+     *     replacePlugin({
+     *       'rtv.e': 'false',
+     *       'rtv.config.enabled': 'false'
+     *     }),
+     *     ...
+     *   ]
+     * };
+     * 
+ * + * The code in the module snippet above would be completely removed from the + * build's output, thereby removing any rtv.js overhead from production. + * * @name rtv.config.enabled * @type {boolean} * @see {@link rtv.enabled} @@ -217,32 +244,9 @@ const rtv = { } }; })() - }), - - /** - * Shortcut proxy for reading {@link rtv.config.enabled}. - * @readonly - * @name rtv.e - * @type {boolean} - */ - get e() { - return this.config.enabled; - } + }) }; -/** - * [Internal] Library version. - * @private - * @name rtv._version - * @type {string} - */ -Object.defineProperty(rtv, '_version', { - enumerable: false, // internal - configurable: true, - writable: true, - value: VERSION -}); - export default rtv; //////////////////////////////////////////////////////////////////////////////// diff --git a/test/lib/RtvError.test.js b/test/lib/RtvError.test.js index 5596084..01a6e4d 100644 --- a/test/lib/RtvError.test.js +++ b/test/lib/RtvError.test.js @@ -255,7 +255,7 @@ describe('module: lib/RtvError', function() { expect(err.failure).to.equal(failure); }); - it('should have custom string serialization', function() { // TODO fix this test + it('should have custom string serialization', function() { const value = null; const path = ['the', 'path']; const failure = new Error('custom validator failed'); diff --git a/test/lib/RtvSuccess.test.js b/test/lib/RtvSuccess.test.js index 4a7a39e..675d7a9 100644 --- a/test/lib/RtvSuccess.test.js +++ b/test/lib/RtvSuccess.test.js @@ -23,7 +23,7 @@ describe('module: lib/RtvSuccess', function() { expect(succ.valid).to.equal(true); }); - it('should have custom string serialization', function() { // TODO fix this test + it('should have custom string serialization', function() { const succ = new RtvSuccess(); const str = succ + ''; expect(str).to.contain('RtvSuccess'); diff --git a/test/lib/impl.test.js b/test/lib/impl.test.js index f0c2d0f..b3abd6c 100644 --- a/test/lib/impl.test.js +++ b/test/lib/impl.test.js @@ -836,13 +836,13 @@ describe('module: lib/impl', function() { it('should throw if the typeset is not an Array', function() { expect(function() { impl.checkWithArray(1, {}); - }).to.throw(/Invalid Array typeset/); + }).to.throw(/Invalid typeset in array/); }); it('should throw if the typeset is not valid', function() { expect(function() { impl.checkWithArray(1, ['invalid-type']); - }).to.throw(/Invalid Array typeset/); + }).to.throw(/Invalid typeset in array/); }); }); }); diff --git a/test/lib/types.test.js b/test/lib/types.test.js index 77d0d2c..6b48901 100644 --- a/test/lib/types.test.js +++ b/test/lib/types.test.js @@ -36,6 +36,7 @@ describe('module: lib/types', function() { types.CLASS_OBJECT ]; + expect(mod.objTypes.$values.length).to.equal(knownTypes.length); expect(_.difference(mod.objTypes.$values, knownTypes)).to.eql([]); expect(mod.objTypes.$name).to.equal('objTypes'); }); @@ -57,11 +58,10 @@ describe('module: lib/types', function() { types.CLASS_OBJECT, types.HASH_MAP, types.MAP, - types.WEAK_MAP, - types.SET, - types.WEAK_SET + types.SET ]; + expect(mod.argTypes.$values.length).to.equal(knownTypes.length); expect(_.difference(mod.argTypes.$values, knownTypes)).to.eql([]); expect(mod.argTypes.$name).to.equal('argTypes'); }); diff --git a/test/lib/validation/isValidator.test.js b/test/lib/validation/isValidator.test.js index a7091d1..c41f036 100644 --- a/test/lib/validation/isValidator.test.js +++ b/test/lib/validation/isValidator.test.js @@ -2,9 +2,9 @@ import {expect} from 'chai'; import * as vtu from '../validationTestUtil'; import types from '../../../src/lib/types'; -import * as val from '../../../src/lib/validation/isValidator'; +import * as val from '../../../src/lib/validation/isCustomValidator'; -describe('module: lib/validation/isValidator', function() { +describe('module: lib/validation/isCustomValidator', function() { it('#type', function() { expect(val.type).to.equal(undefined); }); @@ -17,7 +17,7 @@ describe('module: lib/validation/isValidator', function() { }); it('should validate custom validators', function() { - expect(vtu.testValues('isValidator', val.default, + expect(vtu.testValues('isCustomValidator', val.default, validValues[types.FUNCTION]).failures).to.eql([]); expect(vtu.testOtherValues(types.FUNCTION, val.default)).to.eql([]); }); diff --git a/test/rtv.test.js b/test/rtv.test.js index 2b42024..e927005 100644 --- a/test/rtv.test.js +++ b/test/rtv.test.js @@ -14,6 +14,7 @@ import pkg from '../package.json'; describe('module: rtv', function() { describe('#t', function() { it('should provide all types', function() { + expect('t' in rtv).to.equal(true); expect(rtv.t).to.equal(types); expect(rtv.t instanceof Enumeration).to.equal(true); }); @@ -21,6 +22,7 @@ describe('module: rtv', function() { describe('#q', function() { it('should provide all qualifiers', function() { + expect('q' in rtv).to.equal(true); expect(rtv.q).to.equal(qualifiers); expect(rtv.q instanceof Enumeration).to.equal(true); }); @@ -28,6 +30,7 @@ describe('module: rtv', function() { describe('#isTypeset()', function() { it('should verify a value is a typeset', function() { + expect('isTypeset' in rtv).to.equal(true); expect(rtv.isTypeset({})).to.be.true; expect(rtv.isTypeset([])).to.be.false; }); @@ -56,54 +59,19 @@ describe('module: rtv', function() { }); }); - describe('#_version', function() { - it('should provide version as internal property', function() { - expect(rtv.hasOwnProperty('_version')).to.equal(true); - expect(Object.keys(rtv).indexOf('_version')).to.equal(-1); // not enumerable - expect(Object.getOwnPropertyDescriptor(rtv, '_version')).to.eql({ - value: pkg.version, - enumerable: false, - configurable: true, - writable: true - }); - }); - }); - - describe('#v() proxy', function() { - let spy; - - beforeEach(function() { - spy = sinon.spy(rtv, 'verify'); - }); - - afterEach(function() { - spy.restore(); - }); - - it('should have a shortcut proxy rtv.v()', function() { - expect('v' in rtv).to.equal(true); - expect(_.isFunction(rtv.v)).to.equal(true); - rtv.v('foo', rtv.t.STRING); - expect(spy.called).to.equal(true); + describe('#version', function() { + it('should provide version property', function() { + expect('version' in rtv).to.equal(true); + expect(rtv.version).to.equal(pkg.version); }); }); - describe('#c() proxy', function() { - let spy; - - beforeEach(function() { - spy = sinon.spy(rtv, 'check'); - }); - - afterEach(function() { - spy.restore(); - }); - - it('should have a shortcut proxy rtv.c()', function() { - expect('c' in rtv).to.equal(true); - expect(_.isFunction(rtv.c)).to.equal(true); - rtv.c('foo', rtv.t.STRING); - expect(spy.called).to.equal(true); + describe('#e proxy', function() { + it('should have a shortcut proxy rtv.e -> rtv.config.enabled', function() { + expect('e' in rtv).to.equal(true); + expect(rtv.e).to.equal(rtv.config.enabled); + rtv.config.enabled = false; + expect(rtv.e).to.equal(rtv.config.enabled); }); }); @@ -149,14 +117,5 @@ describe('module: rtv', function() { expect(implCheckSpy.called).to.equal(false); }); }); - - describe('#e proxy', function() { - it('should have a shortcut proxy rtv.e', function() { - expect('e' in rtv).to.equal(true); - expect(rtv.e).to.equal(rtv.config.enabled); - rtv.config.enabled = false; - expect(rtv.e).to.equal(rtv.config.enabled); - }); - }); }); }); diff --git a/tools/internals.js b/tools/internals.js index 05aec25..638a599 100644 --- a/tools/internals.js +++ b/tools/internals.js @@ -11,7 +11,7 @@ import * as isPrimitive from '../src/lib/validation/isPrimitive'; import * as isShape from '../src/lib/validation/isShape'; import * as isTypeArgs from '../src/lib/validation/isTypeArgs'; import * as isTypeset from '../src/lib/validation/isTypeset'; -import * as isValidator from '../src/lib/validation/isValidator'; +import * as isCustomValidator from '../src/lib/validation/isCustomValidator'; // validations import * as isAny from '../src/lib/validation/isAny'; @@ -89,7 +89,7 @@ global.rtvi = { isShape, isTypeArgs, isTypeset, - isValidator, + isCustomValidator, // validations isAny, -- 2.22.2