Support for Precondition error checking in Node.js.
npm install preconditions



#### Support for Precondition error checking in Node.js
Ensuring a fail fast development environment can help developers find bugs quicker and easier.
Ensuring all invariants are true at an initial point of contact will help you ensure this fail fast environment.
The Preconditions library will assist you in doing just that by immediately throwing an Error
if any of your invariants fail. You can mix and match standard Guava API with convenience functions both with
and without chaining.
#### Version 2 Additions
Version 2 adds a new entry point on the interface, 'errr'. The errr interface decorates the errr node module
and helps to solve some important issues with Node, listed below. See https://www.npmjs.com/package/errr.
This version also updates the module to Node 5 paradigms.
1. When templating / generating an error message, we must not string concat strings that are never used. Building an error message before it is needed, will take away cycles from more important tasks in the event queue. There are great performance gains to be found here if you are templating error messages.
2. Appends Error stack traces together. If you append errors at each layer of your code, and only print the stack trace at the top most layer of your code, you will have stack traces that paint a much clearer picture when debugging. Allows you to get a more informative stack trace when using promise chains.
3. Add debug params to stack traces to assist with bug resolution.
npm install preconditions1. errr() - Verify a one value at a time while building an 'errr' object. You can append errors together and add debug params to the stack trace.
2. singleton() - Verify one value at a time with a chainable preconditions interface.
3. instance() - Create a testing suite passing in a single object. Run a single, or multiple tests on the passed in object. Shouldn't be used in production code.
4. constructor() - Get the constructor function so you can extend the Preconditions library (see below for example). Shouldn't be used in production code.
You can use a static instance to verify one value at a time while using the errr module to build an errr. For more on the errr module see here https://github.com/corybill/Preconditions#errrdecorator and here https://github.com/corybill/errr#errr.
var preconditions = require("preconditions").errr();
preconditions.shouldBeDefined(someObj.valueOne).test();
preconditions.shouldBeDefined(someObj.valueOne, "Custom error message.").test();
preconditions.shouldBeDefined(someObj.valueOne, "Error (%s:%s): Error Message.", [errType, errCode]).test();
preconditions.shouldBeDefined(someObj.valueOne, "Custom error message.").debug({param1: "someDebugParam"}).test();
preconditions.shouldBeDefined(someObj.valueOne, "Custom error message.").appendTo(someErrorObj).test();
preconditions.shouldBeDefined(someObj.valueTwo, "Error (%s:%s): Error Message.", [errType, errCode]);
.debug({param1: "someDebugParam"})
.appendTo(someErrorObj)
.test();
Best practice for achieving fail fast concept when function must return promise;
var preconditions = require("preconditions").errr();new BlueBirdProm(function (resolve, reject {
// THIS WILL THROW AND BE CAUGHT AT THE NEXT LEVEL OF THE CHAIN
// NOTICE YOU DO NOT HAVE TO CALL REJECT BECAUSE WE ARE THROWING WITHIN A PROMISE.
preconditions.shouldBeDefined(someObj.valueTwo, "Error (%s:%s): Error Message.", [errType, errCode]);
.debug({param1: "someDebugParam"})
.set("reason", "Some Error").set("statusCode", 400)
.appendTo(someErrorObj)
.test(); // Can also short hand this call to .t();
return someAsynchFunc().then(function (result) {
resolve(result);
}).catch(function (err) {
reject(err);
});
});
You can use a static instance to verify one value at a time.
var preconditions = require("preconditions").singleton();
preconditions.shouldBeDefined(someObj.valueOne)
.shouldBeDefined(someObj.valueTwo, "Error (%s:%s): Error Message.", [errType, errCode]).test();
.shouldBeDefined(someObj.valueThree, "Custom error message.");
#### Setup Instance
var preconditions = require("preconditions").instance(this);
preconditions.shouldBeDefined("foo.deep.stringValue", "Custom error message.")
.checkArguments("FOO" === "FOO");
The Preconditions object itself is exposed so that you can extend the Preconditions class.
let Constructor = preconditions.constructor();
let ChildClass = class extends Constructor {
constructor(out) {
super(out);
}shouldBeFoo(value, message) {
let msg = message || defaultMessage;if (value !== "FOO") {
throw new Error(msg);
}
}
};
new ChildClass(this).shouldBeDefined("foo.deep.stringValue", "Custom error message.")
.shouldBeFoo("foo.deep.foo");
###Known Issues
1. Release 1.0.2 has an npm install bug and has been deprecated! Please update!
2. If you are using windows and are seeing npm install issues due to the '^' in the package.json, please update node to >= (v0.10.28).
Validate values in a nested object using a dot notation structure (e.g. .shouldBeString("Person.Address.Street.zip"))
System will validate the the Person, Person.Address, and Person.Address.Street objects exist, and will validate that zip is a String.
Use this interface if you want to utilize the following functionality:
Validate single value with a chainable interface.
Use this interface if you want to utilize the following functionality:
Error Builder allows you to use optional functions to build an error object. The error can have appended stack traces and debug params to assist with debugging.
Validate single value with a buildable interface on top of the errr node module.
Use this interface if you want to utilize the following functionality:
Preconditions entry point interface.
Use this interface if you want to utilize the following functionality:
1. Nested object validation using a dot notation.
Kind: global class
* InstanceValidator
* new InstanceValidator(objectUnderTest)
* [.shouldBeDefined(configPath, [message])](#InstanceValidator+shouldBeDefined) ⇒ this
* [.shouldBeUndefined(configPath, [message])](#InstanceValidator+shouldBeUndefined) ⇒ this
* [.shouldBeNonEmptyArray(configPath, [message])](#InstanceValidator+shouldBeNonEmptyArray) ⇒ this
* [.shouldBeArray(configPath, [message])](#InstanceValidator+shouldBeArray) ⇒ this
* [.shouldNotBeArray(configPath, [message])](#InstanceValidator+shouldNotBeArray) ⇒ this
* [.shouldBeObject(configPath, [message])](#InstanceValidator+shouldBeObject) ⇒ this
* [.shouldNotBeObject(configPath, [message])](#InstanceValidator+shouldNotBeObject) ⇒ this
* [.shouldBeEmpty(configPath, [message])](#InstanceValidator+shouldBeEmpty) ⇒ this
* [.shouldNotBeEmpty(configPath, [message])](#InstanceValidator+shouldNotBeEmpty) ⇒ this
* [.shouldBeFunction(configPath, [message])](#InstanceValidator+shouldBeFunction) ⇒ this
* [.shouldNotBeFunction(configPath, [message])](#InstanceValidator+shouldNotBeFunction) ⇒ this
* [.shouldBeString(configPath, [message])](#InstanceValidator+shouldBeString) ⇒ this
* [.shouldNotBeString(configPath, [message])](#InstanceValidator+shouldNotBeString) ⇒ this
* [.shouldBeNumber(configPath, [message])](#InstanceValidator+shouldBeNumber) ⇒ this
* [.shouldNotBeNumber(configPath, [message])](#InstanceValidator+shouldNotBeNumber) ⇒ this
* [.shouldBeFinite(configPath, [message])](#InstanceValidator+shouldBeFinite) ⇒ this
* [.shouldBeInfinite(configPath, [message])](#InstanceValidator+shouldBeInfinite) ⇒ this
* [.shouldBeBoolean(configPath, [message])](#InstanceValidator+shouldBeBoolean) ⇒ this
* [.shouldNotBeBoolean(configPath, [message])](#InstanceValidator+shouldNotBeBoolean) ⇒ this
* [.shouldBeDate(configPath, [message])](#InstanceValidator+shouldBeDate) ⇒ this
* [.shouldNotBeDate(configPath, [message])](#InstanceValidator+shouldNotBeDate) ⇒ this
* [.shouldBeRegExp(configPath, [message])](#InstanceValidator+shouldBeRegExp) ⇒ this
* [.shouldNotBeRegExp(configPath, [message])](#InstanceValidator+shouldNotBeRegExp) ⇒ this
* [.shouldBeFalsey(configPath, [message])](#InstanceValidator+shouldBeFalsey) ⇒ this
* [.shouldNotBeFalsey(configPath, [message])](#InstanceValidator+shouldNotBeFalsey) ⇒ this
* [.shouldBeFalsy(configPath, [message])](#InstanceValidator+shouldBeFalsy) ⇒ this
* [.shouldNotBeFalsy(configPath, [message])](#InstanceValidator+shouldNotBeFalsy) ⇒ this
* [.shouldBeTruthy(configPath, [message])](#InstanceValidator+shouldBeTruthy) ⇒ this
* [.shouldNotBeTruthy(configPath, [message])](#InstanceValidator+shouldNotBeTruthy) ⇒ this
* [.checkArgument(expression, [message], [template])](#InstanceValidator+checkArgument) ⇒ this
* [.checkState(expression, [message])](#InstanceValidator+checkState) ⇒ this
* [.checkElementIndex(index, size, [message])](#InstanceValidator+checkElementIndex) ⇒ this
* [.checkPositionIndex(index, size, [message])](#InstanceValidator+checkPositionIndex) ⇒ this
* [.checkPositionIndexes(start, end, size, [message])](#InstanceValidator+checkPositionIndexes) ⇒ this
| Param | Type | Description |
| --- | --- | --- |
| objectUnderTest | Object | Object to run validations against. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| configPath | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| expression | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| expression | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| index | Number | |
| size | Number | |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| index | Number | |
| size | Number | |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: instance method of InstanceValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| start | Number | |
| end | Number | |
| size | Number | |
| [message] | String | The error message or the error template string to use if the validation fails. |
Kind: global class
* SingletonValidator
* [.shouldBeDefined(val, [message], [template])](#SingletonValidator.shouldBeDefined) ⇒ this
* [.shouldBeUndefined(val, [message], [template])](#SingletonValidator.shouldBeUndefined) ⇒ this
* [.shouldBeArray(val, [message], [template])](#SingletonValidator.shouldBeArray) ⇒ this
* [.shouldNotBeArray(val, [message], [template])](#SingletonValidator.shouldNotBeArray) ⇒ this
* [.shouldBeObject(val, [message], [template])](#SingletonValidator.shouldBeObject) ⇒ this
* [.shouldNotBeObject(val, [message], [template])](#SingletonValidator.shouldNotBeObject) ⇒ this
* [.shouldBeEmpty(val, [message], [template])](#SingletonValidator.shouldBeEmpty) ⇒ this
* [.shouldNotBeEmpty(val, [message], [template])](#SingletonValidator.shouldNotBeEmpty) ⇒ this
* [.shouldBeFunction(val, [message], [template])](#SingletonValidator.shouldBeFunction) ⇒ this
* [.shouldNotBeFunction(val, [message], [template])](#SingletonValidator.shouldNotBeFunction) ⇒ this
* [.shouldBeString(val, [message], [template])](#SingletonValidator.shouldBeString) ⇒ this
* [.shouldNotBeString(val, [message], [template])](#SingletonValidator.shouldNotBeString) ⇒ this
* [.shouldBeNumber(val, [message], [template])](#SingletonValidator.shouldBeNumber) ⇒ this
* [.shouldNotBeNumber(val, [message], [template])](#SingletonValidator.shouldNotBeNumber) ⇒ this
* [.shouldBeFinite(val, [message], [template])](#SingletonValidator.shouldBeFinite) ⇒ this
* [.shouldBeInfinite(val, [message], [template])](#SingletonValidator.shouldBeInfinite) ⇒ this
* [.shouldBeBoolean(val, [message], [template])](#SingletonValidator.shouldBeBoolean) ⇒ this
* [.shouldNotBeBoolean(val, [message], [template])](#SingletonValidator.shouldNotBeBoolean) ⇒ this
* [.shouldBeDate(val, [message], [template])](#SingletonValidator.shouldBeDate) ⇒ this
* [.shouldNotBeDate(val, [message], [template])](#SingletonValidator.shouldNotBeDate) ⇒ this
* [.shouldBeRegExp(val, [message], [template])](#SingletonValidator.shouldBeRegExp) ⇒ this
* [.shouldNotBeRegExp(val, [message], [template])](#SingletonValidator.shouldNotBeRegExp) ⇒ this
* [.shouldBeFalsey(val, [message], [template])](#SingletonValidator.shouldBeFalsey) ⇒ this
* [.shouldNotBeFalsey(val, [message], [template])](#SingletonValidator.shouldNotBeFalsey) ⇒ this
* [.shouldBeFalsy(val, [message], [template])](#SingletonValidator.shouldBeFalsy) ⇒ this
* [.shouldNotBeFalsy(val, [message], [template])](#SingletonValidator.shouldNotBeFalsy) ⇒ this
* [.shouldBeTruthy(val, [message], [template])](#SingletonValidator.shouldBeTruthy) ⇒ this
* [.shouldNotBeTruthy(val, [message], [template])](#SingletonValidator.shouldNotBeTruthy) ⇒ this
* [.checkArgument(expression, [message], [template])](#SingletonValidator.checkArgument) ⇒ this
* [.checkState(expression, [message], [template])](#SingletonValidator.checkState) ⇒ this
* [.checkElementIndex(index, size, [message], [template])](#SingletonValidator.checkElementIndex) ⇒ this
* [.checkPositionIndex(index, size, [message], [template])](#SingletonValidator.checkPositionIndex) ⇒ this
* [.checkPositionIndexes(start, end, size, [message], [template])](#SingletonValidator.checkPositionIndexes) ⇒ this
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| val | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| expression | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| expression | String | The value to validate. |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| index | Number | |
| size | Number | |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| index | Number | |
| size | Number | |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: static method of SingletonValidator
Returns: this - - Returns itself to allow chainable validations.
| Param | Type | Description |
| --- | --- | --- |
| start | Number | |
| end | Number | |
| size | Number | |
| [message] | String | The error message or the error template string to use if the validation fails. |
| [template] | Array | Template params. If provided, the error message will be generated using util.format(message, template). |
Kind: global class
* ErrrDecorator
* [new ErrrDecorator([message], [template])](#new_ErrrDecorator_new)
* [.debug(params, [shouldDebug])](#ErrrDecorator+debug) ⇒ ErrrDecorator
* [.set(key, value, [force])](#ErrrDecorator+set) ⇒ ErrrDecorator
* [.setAll(key, value, [force])](#ErrrDecorator+setAll) ⇒ ErrrDecorator
* .appendTo(err) ⇒ ErrrDecorator
* .test()
* .t()
| Param |