accurized
Version:
Verify the validity and accuracy of data as it enters your system.
34 lines (27 loc) • 721 B
JavaScript
(function() {
var Errors,
slice = [].slice;
Errors = (function() {
function Errors() {
this.value = {};
this.empty = true;
}
Errors.prototype.add = function() {
var base, errors, property, ref;
property = arguments[0], errors = 2 <= arguments.length ? slice.call(arguments, 1) : [];
this.empty = false;
if (!errors.length) {
errors = [property];
property = 'global';
}
if ((base = this.value)[property] == null) {
base[property] = {
errors: []
};
}
return (ref = this.value[property].errors).push.apply(ref, errors);
};
return Errors;
})();
module.exports = Errors;
}).call(this);