validation-error
Install
$ npm install --save validation-error
Usage
var ValidationError = require('validation-error');
var ve = ValidationError.of("username", "username is invalid"); // preferred
// OR ValidationError("username", "username is invalid")
// OR new ValidationError("username", "username is invalid")
// concatenate other validation errors
var ve = ValidationError.of("username", "username is invalid");
var ve1 = ValidationError.of("email", "email is invalid")
var ve2 = ve.concat(ve1)
//=> object containg {username: "username is invalid, email: "email is invalid")
view tests for complete specification.
API
.get(key)
Return the value associated with the key, or undefined if the key does not exist
.concat(source, [source, …])
Assigns enumerable own keys of source
objects to a new ValidationError
object and returns it. Additional source
objects will overwrite previous ones. The current instance is not mutated.
.toArray()
Returns the values associated with this-objects enumerable own-properties.
.toObject()
Returns a bare object containing own-properties of this object
License
MIT © Crisson Jno-Charles