Repository: TechnologyAdvice/obey
Pull request #31 (2016-03-09 18:47:56)

Expose API, Generate Docs


Patch:
diff --git a/API.md b/API.md
new file mode 100644
index 0000000..221dd73
--- /dev/null
+++ b/API.md
@@ -0,0 +1,394 @@
+## Objects
+
+<dl>
+<dt><a href="#generators">generators</a> : <code>object</code></dt>
+<dd><p>Generators allow for methods which generate values during validation when a
+value is not supplied</p>
+</dd>
+<dt><a href="#obey">obey</a> : <code>object</code></dt>
+<dd><p>The main object for Obey; exposes the core API methods for standard use as
+well as the API for all other modules</p>
+</dd>
+<dt><a href="#modifiers">modifiers</a> : <code>object</code></dt>
+<dd><p>Modifiers allow for coercion/modification of a value present in the object
+when validation occurs</p>
+</dd>
+<dt><a href="#rules">rules</a> : <code>object</code></dt>
+<dd><p>Rules is responsible for determining the execution of schema definition
+properties during validation</p>
+</dd>
+<dt><a href="#types">types</a> : <code>object</code></dt>
+<dd><p>Types determine and execute the appropriate validation to be performed on an
+object during validation</p>
+</dd>
+</dl>
+
+## Constants
+
+<dl>
+<dt><a href="#addErrors">addErrors</a></dt>
+<dd><p>Adds the error array from a ValidationError&#39;s collection into a parent context&#39;s
+existing collection. This function is curried.</p>
+</dd>
+</dl>
+
+## Functions
+
+<dl>
+<dt><a href="#getMessages">getMessages(msgObjs)</a> ⇒ <code>Array</code></dt>
+<dd><p>Compiles array items into string error messages</p>
+</dd>
+<dt><a href="#ValidationError">ValidationError(message)</a></dt>
+<dd><p>Creates ValidationError object for throwing</p>
+</dd>
+<dt><a href="#validateByKeys">validateByKeys(context, keyPrefix)</a> ⇒ <code>Promise.&lt;Object&gt;</code></dt>
+<dd><p>Validates an object using the definition&#39;s <code>keys</code> property</p>
+</dd>
+<dt><a href="#validateByValues">validateByValues(context, keyPrefix)</a> ⇒ <code>Promise.&lt;Object&gt;</code></dt>
+<dd><p>Validates an object using the definition&#39;s <code>values</code> property</p>
+</dd>
+</dl>
+
+<a name="generators"></a>
+## generators : <code>object</code>
+Generators allow for methods which generate values during validation when a
+value is not supplied
+
+**Kind**: global namespace  
+
+* [generators](#generators) : <code>object</code>
+    * [.lib](#generators.lib)
+    * [.execute(def, key, value)](#generators.execute) ⇒ <code>function</code>
+    * [.add(name, fn)](#generators.add)
+
+<a name="generators.lib"></a>
+### generators.lib
+**Kind**: static property of <code>[generators](#generators)</code>  
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| Library | <code>Object</code> | of generators |
+
+<a name="generators.execute"></a>
+### generators.execute(def, key, value) ⇒ <code>function</code>
+Execute method calls the appropriate generator and returns the method or
+throws and error if the generator does not exist
+
+**Kind**: static method of <code>[generators](#generators)</code>  
+**Returns**: <code>function</code> - The generator function  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| def | <code>Object</code> | The property configuration |
+| key | <code>String</code> | The key name of the property |
+| value | <code>\*</code> | The value being validated |
+
+<a name="generators.add"></a>
+### generators.add(name, fn)
+Adds a generator to the library
+
+**Kind**: static method of <code>[generators](#generators)</code>  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| name | <code>String</code> | The name of the generator |
+| fn | <code>function</code> | The generator's method |
+
+<a name="obey"></a>
+## obey : <code>object</code>
+The main object for Obey; exposes the core API methods for standard use as
+well as the API for all other modules
+
+**Kind**: global namespace  
+
+* [obey](#obey) : <code>object</code>
+    * [.rule(def)](#obey.rule) ⇒ <code>Object</code>
+    * [.model(obj, (strict))](#obey.model) ⇒ <code>Object</code>
+    * [.type(name, handler)](#obey.type)
+    * [.modifier(name, fn)](#obey.modifier)
+    * [.generator(name, fn)](#obey.generator)
+
+<a name="obey.rule"></a>
+### obey.rule(def) ⇒ <code>Object</code>
+Returns a composed rule from a definition object
+
+**Kind**: static method of <code>[obey](#obey)</code>  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| def | <code>Object</code> | The rule definition |
+
+<a name="obey.model"></a>
+### obey.model(obj, (strict)) ⇒ <code>Object</code>
+Returns a composed model from a definition object
+
+**Kind**: static method of <code>[obey](#obey)</code>  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| obj | <code>Object</code> | The definition object |
+| (strict) | <code>Boolean</code> | Whether or not to enforce strict validation |
+
+<a name="obey.type"></a>
+### obey.type(name, handler)
+Creates and stores (or replaces) a type
+
+**Kind**: static method of <code>[obey](#obey)</code>  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| name | <code>String</code> | The name of the type |
+| handler | <code>Object</code> &#124; <code>function</code> | The type method or object of methods |
+
+<a name="obey.modifier"></a>
+### obey.modifier(name, fn)
+Creates and stores a modifier
+
+**Kind**: static method of <code>[obey](#obey)</code>  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| name | <code>String</code> | The modifier's name |
+| fn | <code>function</code> | The method for the modifier |
+
+<a name="obey.generator"></a>
+### obey.generator(name, fn)
+Creates and stores a generator
+
+**Kind**: static method of <code>[obey](#obey)</code>  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| name | <code>String</code> | The generator's name |
+| fn | <code>function</code> | The method for the generator |
+
+<a name="modifiers"></a>
+## modifiers : <code>object</code>
+Modifiers allow for coercion/modification of a value present in the object
+when validation occurs
+
+**Kind**: global namespace  
+
+* [modifiers](#modifiers) : <code>object</code>
+    * [.lib](#modifiers.lib)
+    * [.execute(def, key, value)](#modifiers.execute) ⇒ <code>function</code>
+    * [.add(name, fn)](#modifiers.add)
+
+<a name="modifiers.lib"></a>
+### modifiers.lib
+**Kind**: static property of <code>[modifiers](#modifiers)</code>  
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| Library | <code>Object</code> | of modifiers |
+
+<a name="modifiers.execute"></a>
+### modifiers.execute(def, key, value) ⇒ <code>function</code>
+Execute method calls the appropriate modifier and passes in the value or
+throws an error if the modifier does not exist
+
+**Kind**: static method of <code>[modifiers](#modifiers)</code>  
+**Returns**: <code>function</code> - The modifier function  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| def | <code>Object</code> | The property configuration |
+| key | <code>String</code> | The key name of the property |
+| value | <code>\*</code> | The value being validated |
+
+<a name="modifiers.add"></a>
+### modifiers.add(name, fn)
+Adds new modifier to the library
+
+**Kind**: static method of <code>[modifiers](#modifiers)</code>  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| name | <code>String</code> | The name of the modifier |
+| fn | <code>function</code> | The modifier's method |
+
+<a name="rules"></a>
+## rules : <code>object</code>
+Rules is responsible for determining the execution of schema definition
+properties during validation
+
+**Kind**: global namespace  
+
+* [rules](#rules) : <code>object</code>
+    * [.props](#rules.props)
+    * [.makeValidate(def)](#rules.makeValidate)
+    * [.validate(def, data, (key))](#rules.validate)
+    * [.build(def)](#rules.build) ⇒ <code>Object</code>
+
+<a name="rules.props"></a>
+### rules.props
+**Kind**: static property of <code>[rules](#rules)</code>  
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| Validation | <code>Object</code> | property setup and order of operations |
+
+<a name="rules.makeValidate"></a>
+### rules.makeValidate(def)
+Binds rule definition in validate method
+
+**Kind**: static method of <code>[rules](#rules)</code>  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| def | <code>Object</code> | The rule definition object |
+
+<a name="rules.validate"></a>
+### rules.validate(def, data, (key))
+Iterates over the properties present in the rule definition and sets the
+appropriate bindings to required methods
+
+**Kind**: static method of <code>[rules](#rules)</code>  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| def | <code>Object</code> | The rule definition object |
+| data | <code>\*</code> | The data (value) to validate |
+| (key) | <code>String</code> | Key for tracking parent in nested iterations |
+
+<a name="rules.build"></a>
+### rules.build(def) ⇒ <code>Object</code>
+Adds new rule to the lib
+
+**Kind**: static method of <code>[rules](#rules)</code>  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| def | <code>Object</code> | The rule definition |
+
+<a name="types"></a>
+## types : <code>object</code>
+Types determine and execute the appropriate validation to be performed on an
+object during validation
+
+**Kind**: global namespace  
+
+* [types](#types) : <code>object</code>
+    * [.strategies](#types.strategies)
+    * [.checkSubType(def)](#types.checkSubType) ⇒ <code>Object</code>
+    * [.validate(def, key, value)](#types.validate) ⇒ <code>\*</code>
+    * [.add(name, handler, fn)](#types.add)
+    * [.check(type, val)](#types.check) ⇒ <code>Object</code>
+
+<a name="types.strategies"></a>
+### types.strategies
+**Kind**: static property of <code>[types](#types)</code>  
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| Contains | <code>Object</code> | type strategies |
+
+<a name="types.checkSubType"></a>
+### types.checkSubType(def) ⇒ <code>Object</code>
+Checks for and applies sub-type to definition
+
+**Kind**: static method of <code>[types](#types)</code>  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| def | <code>Object</code> | The rule defintion |
+
+<a name="types.validate"></a>
+### types.validate(def, key, value) ⇒ <code>\*</code>
+Sets up the `fail` method and handles `empty` or `undefined` values. If neither
+empty or undefined, calls the appropriate `type` and executes validation
+
+**Kind**: static method of <code>[types](#types)</code>  
+**Returns**: <code>\*</code> - The value if empty or undefined, check method if value requires type validation  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| def | <code>Object</code> | The property configuration |
+| key | <code>String</code> | The key name of the property |
+| value | <code>\*</code> | The value being validated |
+
+<a name="types.add"></a>
+### types.add(name, handler, fn)
+Add (or override) a type in the library
+
+**Kind**: static method of <code>[types](#types)</code>  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| name | <code>String</code> | The name of the type |
+| handler | <code>Object</code> &#124; <code>function</code> |  |
+| fn | <code>String</code> | The type strategy method |
+
+<a name="types.check"></a>
+### types.check(type, val) ⇒ <code>Object</code>
+Ensures that the strategy exists, loads if not already in memory, then ensures
+subtype and returns the applied type strategy
+
+**Kind**: static method of <code>[types](#types)</code>  
+**Returns**: <code>Object</code> - The type execution function promise resolution  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| type | <code>String</code> | The type to check |
+| val | <code>\*</code> | The value to check |
+
+<a name="addErrors"></a>
+## addErrors
+Adds the error array from a ValidationError's collection into a parent context's
+existing collection. This function is curried.
+
+**Kind**: global constant  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| context | <code>Object</code> | An Obey type context |
+| err | <code>[ValidationError](#ValidationError)</code> | An error to merge with the context's error stack |
+
+<a name="getMessages"></a>
+## getMessages(msgObjs) ⇒ <code>Array</code>
+Compiles array items into string error messages
+
+**Kind**: global function  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| msgObjs | <code>Array</code> | Original array of error message objects |
+
+<a name="ValidationError"></a>
+## ValidationError(message)
+Creates ValidationError object for throwing
+
+**Kind**: global function  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| message | <code>Array</code> | Raw array of error objects |
+
+<a name="validateByKeys"></a>
+## validateByKeys(context, keyPrefix) ⇒ <code>Promise.&lt;Object&gt;</code>
+Validates an object using the definition's `keys` property
+
+**Kind**: global function  
+**Returns**: <code>Promise.&lt;Object&gt;</code> - Resolves with the final object  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| context | <code>Object</code> | An Obey type context |
+| keyPrefix | <code>string</code> | A prefix to include before the key in an error message |
+
+<a name="validateByValues"></a>
+## validateByValues(context, keyPrefix) ⇒ <code>Promise.&lt;Object&gt;</code>
+Validates an object using the definition's `values` property
+
+**Kind**: global function  
+**Returns**: <code>Promise.&lt;Object&gt;</code> - Resolves with the final object  
+
+| Param | Type | Description |
+| --- | --- | --- |
+| context | <code>Object</code> | An Obey type context |
+| keyPrefix | <code>string</code> | A prefix to include before the key in an error message |
+
diff --git a/README.md b/README.md
index a11df65..308b8f2 100644
--- a/README.md
+++ b/README.md
@@ -12,6 +12,7 @@ Asynchronous Data Modelling and Validation.
 
 - [Introduction](#introduction)
 - [Installation](#installation)
+- [API Documentaion](#api-documentation)
 - [Rules](#rules)
 - [Models](#models)
 - [Validation](#validation)
@@ -27,16 +28,21 @@ Asynchronous Data Modelling and Validation.
   - [Creating Generators](#creating-generators)
 - [Strict Mode](#strict-mode)
 - [Asynchronous Validation](#asynchronous-validation)
+- [Contributing](#contributing)
 - [License](#license)
 
 ## Introduction
 
-Obey is a library for creating asynchronous data models and rules. The core goal of the project is to provide methods for managing data models both through synchronous and asynchronous validation and alignment using [JavaScript Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
+Obey is a library for creating asynchronous data models and rules. The core goal of the project is to provide methods for managing data models both through synchronous and asynchronous validation and alignment using [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
 
 ## Installation
 
 Obey can be installed via [NPM](https://www.npmjs.com/package/obey): `npm install obey --save`
 
+## API Documentation
+
+Detailed [API Documentation](API.md) is available for assistance in using, modifying, or [contibuting](#contributing) to the Obey library.
+
 ## Rules
 
 > Rules are core definitions of how a value should be validated:
@@ -290,6 +296,16 @@ user.validate(/* ...some data object... */)
   .catch(/* ...handle errors... */)
 ```
 
+## Contributing
+
+Contibutions to Obey are welcomed and encouraged. If you would like to make a contribution please fork the repository and submit a PR with changes. Acceptance of PR's is based on a review by core contributors. To increase the likelihood of acceptance please ensure the following:
+
+* The PR states the reason for the modification/addition to the API **in detail**
+* All tests are passing and coverage is at, or near, 100%
+* The code submitted follows the conventions used throughout the library
+* [JSDoc](http://usejsdoc.org/) is in place and generates via `npm run doc`
+* Any needed documentation on the `README` is supplied
+
 ## License
 
 Obey is developed and maintained by [TechnologyAdvice](http://www.technologyadvice.com) and released under the [MIT](LICENSE.txt) license.
diff --git a/circle.yml b/circle.yml
index 7fdb8ee..962a5f9 100644
--- a/circle.yml
+++ b/circle.yml
@@ -5,6 +5,7 @@ dependencies:
   override:
     - npm install -g codeclimate-test-reporter
     - npm install -g snyk
+    - npm install -g jsdoc-to-markdown
 general:
   artifacts:
     - coverage
diff --git a/package.json b/package.json
index 268e0dd..43e21fe 100644
--- a/package.json
+++ b/package.json
@@ -9,8 +9,9 @@
   ],
   "scripts": {
     "clean": "rm -rf node_modules",
+    "doc": "node_modules/.bin/jsdoc2md \"src/**/*.js\" > API.md",
     "build": "babel ./src --out-dir ./build",
-    "test": "snyk test && npm run lint && npm run cover",
+    "test": "snyk test && npm run lint && npm run cover && npm run doc",
     "mocha": "babel-node node_modules/.bin/_mocha",
     "cover": "babel-node node_modules/isparta/bin/isparta cover node_modules/mocha/bin/_mocha",
     "lint": "eslint ./src ./test --fix",
@@ -43,6 +44,7 @@
     "chai-as-promised": "^5.2.0",
     "eslint": "~2.1.0",
     "isparta": "~4.0.0",
+    "jsdoc-to-markdown": "^1.3.3",
     "mocha": "~2.2.5",
     "pre-commit": "~1.1.1",
     "sinon": "~1.15.4",
diff --git a/src/generators.js b/src/generators.js
index 62121df..15f71c7 100644
--- a/src/generators.js
+++ b/src/generators.js
@@ -2,19 +2,28 @@
  * Copyright (c) 2015 TechnologyAdvice
  */
 
+/**
+ * Generators allow for methods which generate values during validation when a
+ * value is not supplied
+ * @namespace generators
+ */
 const generators = {
   /**
-   * Library of generators
+   * @memberof generators
+   * @property {Object} Library of generators
    */
   lib: {},
 
   /**
-   * Validator method, used by model
+   * Execute method calls the appropriate generator and returns the method or
+   * throws and error if the generator does not exist
+   * @memberof generators
    * @param {Object} def The property configuration
    * @param {String} key The key name of the property
    * @param {*} value The value being validated
+   * @returns {Function} The generator function
    */
-  validator: function(def, key, value) {
+  execute: function(def, key, value) {
     if (value !== undefined) return value
     if (generators.lib[def.generator]) return generators.lib[def.generator]()
     throw new Error(`Generator '${def.generator}' does not exist`)
@@ -22,6 +31,7 @@ const generators = {
 
   /**
    * Adds a generator to the library
+   * @memberof generators
    * @param {String} name The name of the generator
    * @param {Function} fn The generator's method
    */
diff --git a/src/index.js b/src/index.js
index 7dde417..039889c 100644
--- a/src/index.js
+++ b/src/index.js
@@ -6,13 +6,23 @@ import rules from './rules'
 import types from './types'
 import modifiers from './modifiers'
 import generators from './generators'
+import validators from './lib/validators'
+import ValidationError from './lib/error'
 
 /**
- * This object exposes the top-level public api methods for obey
+ * The main object for Obey; exposes the core API methods for standard use as
+ * well as the API for all other modules
+ * @namespace obey
  */
 export default {
+  /**
+   * API, exposes modules to make lib API accessible
+   */
+  rules, types, modifiers, generators, validators, ValidationError,
+
   /**
    * Returns a composed rule from a definition object
+   * @memberof obey
    * @param {Object} def The rule definition
    * @returns {Object}
    */
@@ -20,6 +30,7 @@ export default {
 
   /**
    * Returns a composed model from a definition object
+   * @memberof obey
    * @param {Object} obj The definition object
    * @param {Boolean} (strict) Whether or not to enforce strict validation
    * @returns {Object}
@@ -28,6 +39,7 @@ export default {
 
   /**
    * Creates and stores (or replaces) a type
+   * @memberof obey
    * @param {String} name The name of the type
    * @param {Object|Function} handler The type method or object of methods
    */
@@ -35,6 +47,7 @@ export default {
 
   /**
    * Creates and stores a modifier
+   * @memberof obey
    * @param {String} name The modifier's name
    * @param {Function} fn The method for the modifier
    */
@@ -42,6 +55,7 @@ export default {
 
   /**
    * Creates and stores a generator
+   * @memberof obey
    * @param {String} name The generator's name
    * @param {Function} fn The method for the generator
    */
diff --git a/src/modifiers.js b/src/modifiers.js
index 849a7f7..c7da7ed 100644
--- a/src/modifiers.js
+++ b/src/modifiers.js
@@ -2,25 +2,35 @@
  * Copyright (c) 2015 TechnologyAdvice
  */
 
+/**
+ * Modifiers allow for coercion/modification of a value present in the object
+ * when validation occurs
+ * @namespace modifiers
+ */
 const modifiers = {
   /**
-   * Library of modifiers
+   * @memberof modifiers
+   * @property {Object} Library of modifiers
    */
   lib: {},
 
   /**
-   * Validator method, used by model
+   * Execute method calls the appropriate modifier and passes in the value or
+   * throws an error if the modifier does not exist
+   * @memberof modifiers
    * @param {Object} def The property configuration
    * @param {String} key The key name of the property
    * @param {*} value The value being validated
+   * @returns {Function} The modifier function
    */
-  validator: function(def, key, value) {
+  execute: function(def, key, value) {
     if (modifiers.lib[def.modifier]) return modifiers.lib[def.modifier](value)
     throw new Error(`Modifier '${def.modifier}' does not exist`)
   },
 
   /**
-   * Adds new modifier
+   * Adds new modifier to the library
+   * @memberof modifiers
    * @param {String} name The name of the modifier
    * @param {Function} fn The modifier's method
    */
diff --git a/src/rules.js b/src/rules.js
index 3d5a91a..9959691 100644
--- a/src/rules.js
+++ b/src/rules.js
@@ -9,22 +9,28 @@ import validators from './lib/validators'
 import ValidationError from './lib/error'
 
 /**
+ * @memberof rules
  * Defines all definition property checks available
  */
 const allProps = {
-  generator: { name: 'generator', fn: generators.validator },
+  generator: { name: 'generator', fn: generators.execute },
   default: { name: 'default', fn: validators.default },
-  modifier: { name: 'modifier', fn: modifiers.validator },
+  modifier: { name: 'modifier', fn: modifiers.execute },
   allow: { name: 'allow', fn: validators.allow },
   min: { name: 'min', fn: validators.min },
   max: { name: 'max', fn: validators.max },
-  type: { name: 'type', fn: types.validator }
+  type: { name: 'type', fn: types.validate }
 }
 
+/**
+ * Rules is responsible for determining the execution of schema definition
+ * properties during validation
+ * @namespace rules
+ */
 const rules = {
   /**
-   * Acts as validation setup for, and respective order of operations
-   * of, properties for a def-prop configuration
+   * @memberof rules
+   * @property {Object} Validation property setup and order of operations
    */
   props: {
     // Default props
@@ -47,14 +53,17 @@ const rules = {
 
   /**
    * Binds rule definition in validate method
+   * @memberof rules
    * @param {Object} def The rule definition object
    */
   makeValidate: def => rules.validate.bind(null, def),
 
   /**
-   * Processes definition validation
+   * Iterates over the properties present in the rule definition and sets the
+   * appropriate bindings to required methods
+   * @memberof rules
    * @param {Object} def The rule definition object
-   * @param {*} data The data to validate
+   * @param {*} data The data (value) to validate
    * @param {String} (key) Key for tracking parent in nested iterations
    */
   validate: (def, data, key = null) => {
@@ -76,7 +85,8 @@ const rules = {
   },
 
   /**
-   * Adds new rule
+   * Adds new rule to the lib
+   * @memberof rules
    * @param {Object} def The rule definition
    * @returns {Object}
    */
diff --git a/src/types.js b/src/types.js
index f1febff..b048a4f 100644
--- a/src/types.js
+++ b/src/types.js
@@ -3,14 +3,21 @@
  */
 import _ from 'lodash'
 
+/**
+ * Types determine and execute the appropriate validation to be performed on the
+ * data during validation
+ * @namespace types
+ */
 const types = {
   /**
-   * Library of type strategies
+   * @memberof types
+   * @property {Object} Contains type strategies
    */
   strategies: {},
 
   /**
    * Checks for and applies sub-type to definition
+   * @memberof types
    * @param {Object} def The rule defintion
    * @returns {Object}
    */
@@ -26,12 +33,15 @@ const types = {
   },
 
   /**
-   * Validator method, used by rules
+   * Sets up the `fail` method and handles `empty` or `undefined` values. If neither
+   * empty or undefined, calls the appropriate `type` and executes validation
+   * @memberof types
    * @param {Object} def The property configuration
    * @param {String} key The key name of the property
    * @param {*} value The value being validated
+   * @returns {*} The value if empty or undefined, check method if value requires type validation
    */
-  validator: function(def, key, value) {
+  validate: function(def, key, value) {
     const parsedDef = types.checkSubType(def)
     const fail = message => {
       this.errors.push({ type: def.type, sub: def.sub, key, value, message })
@@ -50,7 +60,8 @@ const types = {
   },
 
   /**
-   * Add (or override) type in the lib
+   * Add (or override) a type in the library
+   * @memberof types
    * @param {String} name The name of the type
    * @param {Object|Function} handler
    * @param {String} fn The type strategy method
@@ -60,10 +71,12 @@ const types = {
   },
 
   /**
-   * Process basic type validation
+   * Ensures that the strategy exists, loads if not already in memory, then ensures
+   * subtype and returns the applied type strategy
+   * @memberof types
    * @param {String} type The type to check
    * @param {*} val The value to check
-   * @returns {Boolean}
+   * @returns {Object} The type execution function promise resolution
    */
   check: context => {
     if (!types.strategies[context.def.type]) {


Test patch:
diff --git a/test/src/generators.spec.js b/test/src/generators.spec.js
index b8e56ac..009480e 100644
--- a/test/src/generators.spec.js
+++ b/test/src/generators.spec.js
@@ -5,18 +5,18 @@ describe('generators', () => {
   afterEach(() => {
     generators.lib = {}
   })
-  describe('validator', () => {
+  describe('execute', () => {
     it('returns the original value if defined', () => {
-      const actual = generators.validator({}, 'foo', 'bar')
+      const actual = generators.execute({}, 'foo', 'bar')
       expect(actual).to.equal('bar')
     })
     it('returns the modifier method if exists', () => {
       generators.add('test', () => 'foo')
-      const actual = generators.validator({ generator: 'test' }, 'foo')
+      const actual = generators.execute({ generator: 'test' }, 'foo')
       expect(actual).to.be.a.function
     })
     it('throws an error if the generator does not exist', () => {
-      expect(generators.validator.bind(null, { generator: 'nope'})).to.throw('Generator \'nope\' does not exist')
+      expect(generators.execute.bind(null, { generator: 'nope'})).to.throw('Generator \'nope\' does not exist')
     })
   })
   describe('add', () => {
diff --git a/test/src/modifiers.spec.js b/test/src/modifiers.spec.js
index d03e79a..b7ad7c7 100644
--- a/test/src/modifiers.spec.js
+++ b/test/src/modifiers.spec.js
@@ -5,14 +5,14 @@ describe('modifiers', () => {
   afterEach(() => {
     modifiers.lib = {}
   })
-  describe('validator', () => {
+  describe('execute', () => {
     it('returns the modifier method if exists', () => {
       modifiers.add('test', () => 'foo')
-      const actual = modifiers.validator({ modifier: 'test' }, 'foo', 'bar')
+      const actual = modifiers.execute({ modifier: 'test' }, 'foo', 'bar')
       expect(actual).to.be.a.function
     })
     it('throws an error if the modifier does not exist', () => {
-      expect(modifiers.validator.bind(null, { modifier: 'nope' })).to.throw('Modifier \'nope\' does not exist')
+      expect(modifiers.execute.bind(null, { modifier: 'nope' })).to.throw('Modifier \'nope\' does not exist')
     })
   })
   describe('add', () => {
diff --git a/test/src/types.spec.js b/test/src/types.spec.js
index 7cdcb32..a045b1a 100644
--- a/test/src/types.spec.js
+++ b/test/src/types.spec.js
@@ -13,13 +13,13 @@ describe('types', () => {
       expect(actual).to.deep.equal({ type: 'foo', sub: 'bar' })
     })
   })
-  describe('validator', () => {
+  describe('validate', () => {
     it('builds a fail method and returns types.check', () => {
-      const actual = types.validator.call({ errors: [] }, { type: 'string' }, 'foo', 'bar')
+      const actual = types.validate.call({ errors: [] }, { type: 'string' }, 'foo', 'bar')
       expect(actual).to.be.a.function
     })
     it('allows an empty string to pass (via return) when empty flag is set', () => {
-      const actual = types.validator.call({ errors: [] }, { type: 'string', empty: true }, 'foo', '')
+      const actual = types.validate.call({ errors: [] }, { type: 'string', empty: true }, 'foo', '')
       expect(actual).to.equal('')
     })
   })