approve

approve

Source:

Namespaces

tests

Methods

(static) addTest(obj, name)

Source:
Used to add custom tests.
Example
var test = {
   expects: false,
   message: '{title} did not pass the test.',
   validate: function(value) {
       return this.strength(value);
   },
};
approve.addTest(test, 'test_name');
Parameters:
Name Type Description
obj Object The test object to add.
name String The name of the test.
Returns:
void

(static) noconflict()

Source:
Returns the root approve variable back to the previous object
Example
var approveObj = approve.noconflict();
opproveObj.value(...);
Returns:
this

(static) value(value, rules, titleopt) → {Object}

Source:
Executes the tests based on given rules to validate a given value.

Returns an object with at least two properties:
approved : Boolean - true if test succeeded, otherwise false.
errors : Array of String - holds a list of formatted errors.
Example
var result = approve.value('some value', {test: constraints});
if (result.approved) {
   // Value is approved - do something
} else {
   // Do something with the errors
   result.each(function(error) {
      console.log(error);
   });
}
Parameters:
Name Type Attributes Description
value String | Integer The value to test against the rules.
rules Object The constraints for the value being tested.
title String <optional>
The title to replace the {title} placeholder in error messages with.
Returns:
The object containing the result of the tests performed.
Type
Object