Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-data-schema

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-data-schema - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

6

CHANGELOG.md

@@ -0,1 +1,7 @@

##### 1.2.2 - 07 April 2015
###### Backwards compatible bug fixes
- #13 - Check for instance wherel rule is undefined - thanks to @facultymatt for the PR!
- #14 - Errors are not properly collected for nested properties
##### 1.2.1 - 03 April 2015

@@ -2,0 +8,0 @@

227

dist/js-data-schema.js
/*!
* js-data-schema
* @version 1.2.1 - Homepage <https://github.com/js-data/js-data-schema/>
* @version 1.2.2 - Homepage <https://github.com/js-data/js-data-schema/>
* @author Jason Dobry <jason.dobry@gmail.com>

@@ -499,2 +499,13 @@ * @copyright (c) 2013-2015 Jason Dobry

var hasObject = function (v) {
var has = false;
utils.forOwn(v, function (_v) {
if (utils.isObject(_v)) {
has = true;
return false;
}
});
return has;
};
function _executeRulesSync(targetKey, options, errors, value, key) {

@@ -504,4 +515,5 @@ var _this = this;

var nestedKey = targetKey + (targetKey.length ? "." : "") + key;
var schemaRules = utils.get(this.schema, nestedKey);
if (utils.isObject(value)) {
if (utils.isObject(value) || hasObject(schemaRules)) {
var err = _validateSync.apply(this, [nestedKey, value, options]);

@@ -512,3 +524,2 @@ if (err) {

} else {
var schemaRules = utils.get(this.schema, nestedKey);
if (!utils.isObject(schemaRules)) {

@@ -526,3 +537,3 @@ return;

var rule = _this.parent.rules[ruleKey] || defaultRules[ruleKey];
if (!rule.async) {
if (rule && !rule.async) {
var err = rule.call(options.ctx, value, ruleValue, undefined, _this.parent);

@@ -581,4 +592,5 @@ if (err) {

var nestedKey = prefix + key;
var schemaRules = utils.get(this.schema, nestedKey);
if (utils.isObject(value)) {
if (utils.isObject(value) || hasObject(schemaRules)) {
// Recurse down into nested attributes

@@ -591,3 +603,2 @@ deepQueue[key] = (function (nK, val) {

} else {
var schemaRules = utils.get(this.schema, nestedKey);
if (!utils.isObject(schemaRules)) {

@@ -606,3 +617,3 @@ return;

// Asynchronous rules get added to the queue
if (rule.async) {
if (rule && rule.async) {
ruleQueue["" + ruleKey + "_" + ruleValue] = (function (r, key, val, rVal) {

@@ -1338,3 +1349,3 @@ return function (next) {

var indexOf = __webpack_require__(42);
var indexOf = __webpack_require__(40);

@@ -1356,4 +1367,4 @@ /**

var unique = __webpack_require__(29);
var filter = __webpack_require__(40);
var every = __webpack_require__(41);
var filter = __webpack_require__(41);
var every = __webpack_require__(42);
var contains = __webpack_require__(26);

@@ -1387,3 +1398,3 @@ var slice = __webpack_require__(36);

var unique = __webpack_require__(29);
var filter = __webpack_require__(40);
var filter = __webpack_require__(41);
var some = __webpack_require__(43);

@@ -1416,3 +1427,3 @@ var contains = __webpack_require__(26);

var filter = __webpack_require__(40);
var filter = __webpack_require__(41);

@@ -1673,5 +1684,5 @@ /**

var identity = __webpack_require__(46);
var prop = __webpack_require__(47);
var deepMatches = __webpack_require__(48);
var identity = __webpack_require__(45);
var prop = __webpack_require__(46);
var deepMatches = __webpack_require__(47);

@@ -1714,3 +1725,3 @@ /**

var clone = __webpack_require__(45);
var clone = __webpack_require__(48);
var forOwn = __webpack_require__(19);

@@ -1790,2 +1801,36 @@ var kindOf = __webpack_require__(44);

/**
* Array.indexOf
*/
function indexOf(arr, item, fromIndex) {
fromIndex = fromIndex || 0;
if (arr == null) {
return -1;
}
var len = arr.length,
i = fromIndex < 0 ? len + fromIndex : fromIndex;
while (i < len) {
// we iterate over sparse items since there is no way to make it
// work properly on IE 7-8. see #64
if (arr[i] === item) {
return i;
}
i++;
}
return -1;
}
module.exports = indexOf;
/***/ },
/* 41 */
/***/ function(module, exports, __webpack_require__) {
var makeIterator = __webpack_require__(37);

@@ -1820,3 +1865,3 @@

/***/ },
/* 41 */
/* 42 */
/***/ function(module, exports, __webpack_require__) {

@@ -1854,36 +1899,2 @@

/***/ },
/* 42 */
/***/ function(module, exports, __webpack_require__) {
/**
* Array.indexOf
*/
function indexOf(arr, item, fromIndex) {
fromIndex = fromIndex || 0;
if (arr == null) {
return -1;
}
var len = arr.length,
i = fromIndex < 0 ? len + fromIndex : fromIndex;
while (i < len) {
// we iterate over sparse items since there is no way to make it
// work properly on IE 7-8. see #64
if (arr[i] === item) {
return i;
}
i++;
}
return -1;
}
module.exports = indexOf;
/***/ },
/* 43 */

@@ -1951,57 +1962,2 @@ /***/ function(module, exports, __webpack_require__) {

var kindOf = __webpack_require__(44);
var isPlainObject = __webpack_require__(33);
var mixIn = __webpack_require__(49);
/**
* Clone native types.
*/
function clone(val){
switch (kindOf(val)) {
case 'Object':
return cloneObject(val);
case 'Array':
return cloneArray(val);
case 'RegExp':
return cloneRegExp(val);
case 'Date':
return cloneDate(val);
default:
return val;
}
}
function cloneObject(source) {
if (isPlainObject(source)) {
return mixIn({}, source);
} else {
return source;
}
}
function cloneRegExp(r) {
var flags = '';
flags += r.multiline ? 'm' : '';
flags += r.global ? 'g' : '';
flags += r.ignoreCase ? 'i' : '';
return new RegExp(r.source, flags);
}
function cloneDate(date) {
return new Date(+date);
}
function cloneArray(arr) {
return arr.slice();
}
module.exports = clone;
/***/ },
/* 46 */
/***/ function(module, exports, __webpack_require__) {

@@ -2022,3 +1978,3 @@

/***/ },
/* 47 */
/* 46 */
/***/ function(module, exports, __webpack_require__) {

@@ -2043,3 +1999,3 @@

/***/ },
/* 48 */
/* 47 */
/***/ function(module, exports, __webpack_require__) {

@@ -2105,2 +2061,57 @@

/***/ },
/* 48 */
/***/ function(module, exports, __webpack_require__) {
var kindOf = __webpack_require__(44);
var isPlainObject = __webpack_require__(33);
var mixIn = __webpack_require__(49);
/**
* Clone native types.
*/
function clone(val){
switch (kindOf(val)) {
case 'Object':
return cloneObject(val);
case 'Array':
return cloneArray(val);
case 'RegExp':
return cloneRegExp(val);
case 'Date':
return cloneDate(val);
default:
return val;
}
}
function cloneObject(source) {
if (isPlainObject(source)) {
return mixIn({}, source);
} else {
return source;
}
}
function cloneRegExp(r) {
var flags = '';
flags += r.multiline ? 'm' : '';
flags += r.global ? 'g' : '';
flags += r.ignoreCase ? 'i' : '';
return new RegExp(r.source, flags);
}
function cloneDate(date) {
return new Date(+date);
}
function cloneArray(arr) {
return arr.slice();
}
module.exports = clone;
/***/ },
/* 49 */

@@ -2107,0 +2118,0 @@ /***/ function(module, exports, __webpack_require__) {

/*!
* js-data-schema
* @version 1.2.1 - Homepage <https://github.com/js-data/js-data-schema/>
* @version 1.2.2 - Homepage <https://github.com/js-data/js-data-schema/>
* @author Jason Dobry <jason.dobry@gmail.com>

@@ -11,3 +11,3 @@ * @copyright (c) 2013-2014 Jason Dobry <https://github.io/js-data/js-data-schema>

!function(a,b){"object"==typeof exports&&"object"==typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):"object"==typeof exports?exports.Schemator=b():a.Schemator=b()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){var d=function(a){return a&&a.__esModule?a["default"]:a},e=function(){function a(a,b){for(var c in b){var d=b[c];d.configurable=!0,d.value&&(d.writable=!0)}Object.defineProperties(a,b)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),f=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")},g=d(c(1)),h=d(c(2)),i=d(c(3)),j=d(c(4)),k=1,l=function(){function a(){f(this,a),this.dataTypes={},this.rules={},this.schemata={},this.id=k++}return e(a,{availableDataTypes:{value:function(){return g.unique(g.keys(this.dataTypes).concat(g.keys(h)))}},availableRules:{value:function(){return g.unique(g.keys(this.rules).concat(g.keys(i)))}},availableSchemata:{value:function(){return g.keys(this.schemata)}},defineDataType:{value:function(a,b){if(!g.isString(a))throw new Error('"name" must be a string!');if(!g.isFunction(b))throw new Error('"typeDefinition" must be a function!');if(this.dataTypes[a])throw new Error("dataType already registered!");this.dataTypes[a]=b}},defineRule:{value:function(a,b,c){if(!g.isString(a))throw new Error('"name" must be a string!');if(!g.isFunction(b))throw new Error('"ruleFunc" must be a function!');if(this.rules[a])throw new Error("rule already registered!");this.rules[a]=b,this.rules[a].async=!!c}},defineSchema:{value:function(a,b){if(this.schemata[a])throw new Error("schema already registered!");if(b instanceof j)throw new Error("schema registered elsewhere!");return this.schemata[a]=new j(a,b,this),this.schemata[a].parent=this,this.schemata[a]}},getDataType:{value:function(a){return this.dataTypes[a]||h[a]}},getRule:{value:function(a){return this.rules[a]||i[a]}},getSchema:{value:function(a){return this.schemata[a]}},removeDataType:{value:function(a){delete this.dataTypes[a]}},removeRule:{value:function(a){delete this.rules[a]}},removeSchema:{value:function(a){delete this.schemata[a]}},schemaCheck:{value:function(a){if(!this.schemata[a])throw new Error("schema is not registered!")}},validateSync:{value:function(a,b,c){return this.schemaCheck(a),this.schemata[a].validateSync(b,c)}},validate:{value:function(a,b,c,d){return this.schemaCheck(a),this.schemata[a].validate(b,c,d)}},addDefaultsToTarget:{value:function(a,b,c){return this.schemaCheck(a),this.schemata[a].addDefaultsToTarget(b,c)}},setDefaults:{value:function(a,b){return this.schemaCheck(a),this.schemata[a].setDefaults(b)}},getDefaults:{value:function(a){return this.schemaCheck(a),this.schemata[a].getDefaults()}},stripNonSchemaAttrs:{value:function(a,b){return this.schemaCheck(a),this.schemata[a].stripNonSchemaAttrs(b)}}}),a}();a.exports=l},function(a,b,c){var d=function(a){return a&&a.__esModule?a["default"]:a},e=d(c(5)),f=d(c(6)),g=d(c(7)),h=d(c(8)),i=d(c(9)),j=d(c(10)),k=d(c(11)),l=d(c(12)),m=d(c(13)),n=d(c(14)),o=d(c(15)),p=d(c(16)),q=d(c(17)),r=d(c(18)),s=d(c(19)),t=d(c(20)),u=d(c(21)),v=d(c(22)),w=d(c(23)),x=d(c(24)),y=d(c(25)),z=d(c(26)),A=d(c(27)),B=d(c(28)),C=d(c(29)),D=d(c(30));a.exports={isString:e,isBoolean:f,isNumber:g,isObject:h,isDate:i,isFunction:j,isUndefined:k,isArray:l,isEmpty:m,toString:n,toNumber:o,get:p,deepMixIn:q,deepFillIn:r,forOwn:s,keys:t,pick:u,filter:v,map:w,merge:x,unset:y,contains:z,intersection:A,difference:B,unique:C,toInt:D,errMsg:function(a,b,c){return{rule:a,actual:b,expected:c}},parallel:function(a,b){function c(a){e+=1,(a||e>=f)&&b(a,d)}var d={},e=0,f=0;s(a,function(){f+=1}),s(a,function(a,b){a(function(a){var e=Array.prototype.slice.call(arguments,1);e.length<=1&&(e=e[0]),d[b]=e,c(a)})})}}},function(a,b,c){var d=function(a){return a&&a.__esModule?a["default"]:a},e=d(c(1));a.exports={string:function(a){return e.isString(a)?null:e.errMsg("type",typeof a,"string")},number:function(a){return e.isNumber(a)?null:e.errMsg("type",typeof a,"number")},integer:function(a){return e.isNumber(a)?Math.abs(a)-Math.abs(e.toInt(a))!==0?e.errMsg("type","real","integer"):null:e.errMsg("type",typeof a,"integer")},"float":function(a){return e.isNumber(a)?null:e.errMsg("type",typeof a,"float")},array:function(a){return e.isArray(a)?null:e.errMsg("type",typeof a,"array")},object:function(a){return e.isObject(a)?null:e.errMsg("type",typeof a,"object")},"boolean":function(a){return e.isBoolean(a)?null:e.errMsg("type",typeof a,"boolean")},date:function(a){return e.isDate(a)?null:e.errMsg("type",typeof a,"date")}}},function(a,b,c){var d=function(a){return a&&a.__esModule?a["default"]:a},e=d(c(1)),f=d(c(2));a.exports={nullable:function(a){var b=function(){return a.apply(this,arguments)};return b.toString=function(){return a.toString()},b}(function(a,b){return null!==a&&void 0!==a||b?null:e.errMsg("nullable","x === "+a,"x !== null && x !== undefined")}),max:function(a){var b=function(){return a.apply(this,arguments)};return b.toString=function(){return a.toString()},b}(function(a,b){return e.isNumber(a)&&e.isNumber(b)&&a>b?e.errMsg("max",""+a+" > "+b,""+a+" <= "+b):null}),min:function(a){var b=function(){return a.apply(this,arguments)};return b.toString=function(){return a.toString()},b}(function(a,b){return e.isNumber(a)&&e.isNumber(b)&&b>a?e.errMsg("min",""+a+" < "+b,""+a+" >= "+b):null}),maxLength:function(a){var b=function(){return a.apply(this,arguments)};return b.toString=function(){return a.toString()},b}(function(a,b){return(e.isString(a)||e.isArray(a))&&e.isNumber(b)&&a.length>b?e.errMsg("maxLength",""+a.length+" > "+b,""+a.length+" <= "+b):null}),minLength:function(a){var b=function(){return a.apply(this,arguments)};return b.toString=function(){return a.toString()},b}(function(a,b){return(e.isString(a)||e.isArray(a))&&e.isNumber(b)&&a.length<b?e.errMsg("minLength",""+a.length+" < "+b,""+a.length+" >= "+b):null}),type:function(a){var b=function(){return a.apply(this,arguments)};return b.toString=function(){return a.toString()},b}(function(a,b,c,d){return c?c(a):d.dataTypes[b]?d.dataTypes[b](a):f[b]?f[b](a):null})}},function(a,b,c){function d(a,b,c,d,f){var g=this,h=a+(a.length?".":"")+f;if(m.isObject(d)){var i=e.apply(this,[h,d,b]);i&&(c[f]=i)}else{var j=m.get(this.schema,h);if(!m.isObject(j))return;if(j.nullable===!0){var k=this.parent.rules.nullable||n.nullable,l=k.call(b.ctx,d,!0,void 0,this.parent);if(null===l)return}m.forOwn(j,function(a,e){var h=g.parent.rules[e]||n[e];if(!h.async){var i=h.call(b.ctx,d,a,void 0,g.parent);i&&(c[f]||(c[f]={errors:[]}),c[f].errors.push(i))}})}}function e(a,b,c){var e=this,f={};try{if(m.forOwn(b,function(b,g){d.call(e,a,c,f,b,g)}),!c.ignoreMissing){var g=a?m.get(this.schema,a)||{}:this.schema,h=m.difference(m.keys(g),m.keys(b));h=m.pick(this.schema,h),h=m.map(h,function(){return void 0}),m.forOwn(h,function(b,g){d.call(e,a,c,f,b,g)})}return m.isEmpty(f)?null:f}catch(i){return i}}function f(a,b,c,d,e,f,h){var i=this,j=d+c;if(m.isObject(b))f[c]=function(b,c){return function(d){g.apply(i,[b,c,a,d])}}(j,b);else{var k=m.get(this.schema,j);if(!m.isObject(k))return;if(k.nullable===!0){var l=this.parent.rules.nullable||n.nullable,o=l.call(a.ctx,b,!0,void 0,this.parent);if(null===o)return}m.forOwn(k,function(d,f){var g=i.parent.rules[f]||n[f];if(g.async)h[""+f+"_"+d]=function(b,c,d,e){return function(f){b.call(a.ctx,d,e,function(a){f(null,{err:a,key:c})})}}(g,c,b,d);else{var j=g.call(a.ctx,b,d,void 0,i.parent);j&&(e[c]||(e[c]={errors:[]}),e[c].errors.push(j))}})}}function g(a,b,c,d){var e=this,g={},h=a+(a.length?".":""),i={},j={},k=c.first;if(delete c.first,m.forOwn(b,function(a,b){f.call(e,c,a,b,h,g,i,j)}),!c.ignoreMissing){var l=a?m.get(this.schema,a)||{}:this.schema,n=m.difference(m.keys(l),m.keys(b));n=m.pick(this.schema,n),n=m.map(n,function(){return void 0}),m.forOwn(n,function(a,b){f.call(e,c,a,b,h,g,i,j)})}var o={};m.isEmpty(i)||(o.deepQueue=function(a){m.parallel(i,a)}),m.isEmpty(j)||(o.ruleQueue=function(a){m.parallel(j,a)}),m.isEmpty(o)?m.isEmpty(g)?d(null):k?d(g):d(null,g):m.parallel(o,function(a,b){b.deepQueue&&(b.deepQueue=m.filter(b.deepQueue,function(a){return void 0!==a&&null!==a}),m.deepMixIn(g,b.deepQueue)),b.ruleQueue&&(b.ruleQueue&&(b.ruleQueue=m.filter(b.ruleQueue,function(a){return void 0!==a.err&&null!==a.err})),m.forOwn(b.ruleQueue,function(a){g[a.key]||(g[a.key]={errors:[]}),g[a.key].errors.push(a.err)})),m.isEmpty(g)?d(null):k?d(g):d(null,g)})}function h(a,b){b=b||[];var c=m.keys(a),d=0===m.intersection(c,b).length;m.forOwn(a,function(c,e){if(d&&m.isString(c))a[e]={type:c};else if(m.isObject(c)){if(m.contains(b,e))throw new Error('Rule configuration for rule "'+e+'" cannot be an object!');h(c,b)}})}function i(a,b){m.forOwn(a,function(c,d){b[d]?m.isObject(c)&&m.isObject(b[d])&&i(c,b[d]):m.unset(a,d)})}var j=function(a){return a&&a.__esModule?a["default"]:a},k=function(){function a(a,b){for(var c in b){var d=b[c];d.configurable=!0,d.value&&(d.writable=!0)}Object.defineProperties(a,b)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),l=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")},m=j(c(1)),n=j(c(3)),o={a:"Schema#validateSync(attrs[, options]): ",b:"Schema#validate(attrs[, options], cb): "},p=function(){function a(b,c,d){if(l(this,a),!m.isString(b))throw new Error('"name" must be a string!');if(!m.isObject(c))throw new Error('"schema" must be an object!');this.name=b,h(c,d?d.availableRules():n),this.schema=c}return k(a,{validateSync:{value:function(a,b){if(b=b?b===!0?{ignoreMissing:!0}:b:{},!m.isObject(a))throw new Error(""+o.a+"attrs: Must be an object!");if(!m.isObject(b))throw new Error(""+o.a+"options: Must be an object!");return b.ctx=a,e.call(this,"",a,b)}},validate:{value:function(a,b,c){if(b=b?b===!0?{ignoreMissing:!0}:b:{},m.isFunction(b)&&(c=b,b={}),!m.isFunction(c))throw new Error(""+o.b+"cb: Must be a function!");return m.isObject(a)?m.isObject(b)?(b.first=!0,b.ctx=a,void g.call(this,"",a,b,c)):c(new Error(""+o.b+"options: Must be an object!")):c(new Error(""+o.b+"attrs: Must be an object!"))}},addDefaultsToTarget:{value:function(a,b){if(!m.isObject(a))throw new Error('"target" must be an object!');if(!this.defaults)throw new Error("No defaults have been set!");b?m.deepMixIn(a,this.defaults):m.deepFillIn(a,this.defaults)}},setDefaults:{value:function(a){if(!m.isObject(a))throw new Error("Schema#defaults(attrs): attrs: Must be an object!");return this.defaults=m.merge({},a),this}},getDefaults:{value:function(){return m.merge({},this.defaults)}},stripNonSchemaAttrs:{value:function(a){return i(a,this.schema),a}}}),a}();a.exports=p},function(a,b,c){function d(a){return e(a,"String")}var e=c(31);a.exports=d},function(a,b,c){function d(a){return e(a,"Boolean")}var e=c(31);a.exports=d},function(a,b,c){function d(a){return e(a,"Number")}var e=c(31);a.exports=d},function(a,b,c){function d(a){return e(a,"Object")}var e=c(31);a.exports=d},function(a,b,c){function d(a){return e(a,"Date")}var e=c(31);a.exports=d},function(a,b,c){function d(a){return e(a,"Function")}var e=c(31);a.exports=d},function(a){function b(a){return a===c}var c;a.exports=b},function(a,b,c){var d=c(31),e=Array.isArray||function(a){return d(a,"Array")};a.exports=e},function(a,b,c){function d(a){if(null==a)return!0;if("string"==typeof a||f(a))return!a.length;if("object"==typeof a){var b=!0;return e(a,function(){return b=!1,!1}),b}return!0}var e=c(19),f=c(12);a.exports=d},function(a){function b(a){return null==a?"":a.toString()}a.exports=b},function(a,b,c){function d(a){return"number"==typeof a?a:a?"string"==typeof a?parseFloat(a):e(a)?0/0:Number(a):0}var e=c(12);a.exports=d},function(a,b,c){function d(a,b){for(var c=b.split("."),d=c.pop();b=c.shift();)if(a=a[b],null==a)return;return a[d]}c(32);a.exports=d},function(a,b,c){function d(a){for(var b,c=0,d=arguments.length;++c<d;)b=arguments[c],b&&f(b,e,a);return a}function e(a,b){var c=this[b];g(a)&&g(c)?d(c,a):this[b]=a}var f=c(19),g=c(33);a.exports=d},function(a,b,c){function d(a){for(var b,c=0,g=arguments.length;++c<g;)b=arguments[c],b&&e(b,function(b,c){var e=a[c];null==e?a[c]=b:f(e)&&f(b)&&d(e,b)});return a}var e=c(19),f=c(33);a.exports=d},function(a,b,c){function d(a,b,c){f(a,function(d,f){return e(a,f)?b.call(c,a[f],f,a):void 0})}var e=c(34),f=c(35);a.exports=d},function(a,b,c){var d=c(19),e=Object.keys||function(a){var b=[];return d(a,function(a,c){b.push(c)}),b};a.exports=e},function(a,b,c){function d(a){for(var b,c="string"!=typeof arguments[1]?arguments[1]:e(arguments,1),d={},f=0;b=c[f++];)d[b]=a[b];return d}var e=c(36);a.exports=d},function(a,b,c){function d(a,b,c){b=f(b,c);var d={};return e(a,function(a,c,e){b(a,c,e)&&(d[c]=a)}),d}var e=c(19),f=c(37);a.exports=d},function(a,b,c){function d(a,b,c){b=f(b,c);var d={};return e(a,function(a,c,e){d[c]=b(a,c,e)}),d}var e=c(19),f=c(37);a.exports=d},function(a,b,c){function d(){var a,b,c,h,i=1;for(h=f(arguments[0]);c=arguments[i++];)for(a in c)e(c,a)&&(b=c[a],h[a]=g(b)&&g(h[a])?d(h[a],b):f(b));return h}var e=c(34),f=c(38),g=c(8);a.exports=d},function(a,b,c){function d(a,b){if(e(a,b)){for(var c=b.split("."),d=c.pop();b=c.shift();)a=a[b];return delete a[d]}return!0}var e=c(39);a.exports=d},function(a,b,c){function d(a,b){return-1!==e(a,b)}var e=c(42);a.exports=d},function(a,b,c){function d(a){var b=i(arguments,1),c=f(e(a),function(a){return g(b,function(b){return h(b,a)})});return c}var e=c(29),f=c(40),g=c(41),h=c(26),i=c(36);a.exports=d},function(a,b,c){function d(a){var b=i(arguments,1),c=f(e(a),function(a){return!g(b,function(b){return h(b,a)})});return c}var e=c(29),f=c(40),g=c(43),h=c(26),i=c(36);a.exports=d},function(a,b,c){function d(a,b){return b=b||e,f(a,function(a,c,d){for(var e=d.length;++c<e;)if(b(a,d[c]))return!1;return!0})}function e(a,b){return a===b}var f=c(40);a.exports=d},function(a){function b(a){return~~a}a.exports=b},function(a,b,c){function d(a,b){return e(a)===b}var e=c(44);a.exports=d},function(a){function b(a){switch(typeof a){case"string":case"number":case"boolean":return!0}return null==a}a.exports=b},function(a){function b(a){return!!a&&"object"==typeof a&&a.constructor===Object}a.exports=b},function(a){function b(a,b){return Object.prototype.hasOwnProperty.call(a,b)}a.exports=b},function(a,b,c){function d(){h=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],g=!0;for(var a in{toString:null})g=!1}function e(a,b,c){var e,j=0;null==g&&d();for(e in a)if(f(b,a,e,c)===!1)break;if(g)for(var k=a.constructor,l=!!k&&a===k.prototype;(e=h[j++])&&("constructor"===e&&(l||!i(a,e))||a[e]===Object.prototype[e]||f(b,a,e,c)!==!1););}function f(a,b,c,d){return a.call(d,b[c],c,b)}var g,h,i=c(34);a.exports=e},function(a){function b(a,b,c){var d=a.length;b=null==b?0:0>b?Math.max(d+b,0):Math.min(b,d),c=null==c?d:0>c?Math.max(d+c,0):Math.min(c,d);for(var e=[];c>b;)e.push(a[b++]);return e}a.exports=b},function(a,b,c){function d(a,b){if(null==a)return e;switch(typeof a){case"function":return"undefined"!=typeof b?function(c,d,e){return a.call(b,c,d,e)}:a;case"object":return function(b){return g(b,a)};case"string":case"number":return f(a)}}var e=c(46),f=c(47),g=c(48);a.exports=d},function(a,b,c){function d(a,b){switch(i(a)){case"Object":return e(a,b);case"Array":return f(a,b);default:return g(a)}}function e(a,b){if(j(a)){var c={};return h(a,function(a,c){this[c]=d(a,b)},c),c}return b?b(a):a}function f(a,b){for(var c=[],e=-1,f=a.length;++e<f;)c[e]=d(a[e],b);return c}var g=c(45),h=c(19),i=c(44),j=c(33);a.exports=d},function(a,b,c){function d(a,b){return f(a,b)!==e}var e,f=c(16);a.exports=d},function(a,b,c){function d(a,b,c){b=e(b,c);var d=[];if(null==a)return d;for(var f,g=-1,h=a.length;++g<h;)f=a[g],b(f,g,a)&&d.push(f);return d}var e=c(37);a.exports=d},function(a,b,c){function d(a,b,c){b=e(b,c);var d=!0;if(null==a)return d;for(var f=-1,g=a.length;++f<g;)if(!b(a[f],f,a)){d=!1;break}return d}var e=c(37);a.exports=d},function(a){function b(a,b,c){if(c=c||0,null==a)return-1;for(var d=a.length,e=0>c?d+c:c;d>e;){if(a[e]===b)return e;e++}return-1}a.exports=b},function(a,b,c){function d(a,b,c){b=e(b,c);var d=!1;if(null==a)return d;for(var f=-1,g=a.length;++f<g;)if(b(a[f],f,a)){d=!0;break}return d}var e=c(37);a.exports=d},function(a){function b(a){return null===a?"Null":a===c?"Undefined":d.exec(e.call(a))[1]}var c,d=/^\[object (.*)\]$/,e=Object.prototype.toString;a.exports=b},function(a,b,c){function d(a){switch(i(a)){case"Object":return e(a);case"Array":return h(a);case"RegExp":return f(a);case"Date":return g(a);default:return a}}function e(a){return j(a)?k({},a):a}function f(a){var b="";return b+=a.multiline?"m":"",b+=a.global?"g":"",b+=a.ignoreCase?"i":"",new RegExp(a.source,b)}function g(a){return new Date(+a)}function h(a){return a.slice()}var i=c(44),j=c(33),k=c(49);a.exports=d},function(a){function b(a){return a}a.exports=b},function(a){function b(a){return function(b){return b[a]}}a.exports=b},function(a,b,c){function d(a,b){for(var c=-1,d=a.length;++c<d;)if(g(a[c],b))return!0;return!1}function e(a,b){for(var c=-1,e=b.length;++c<e;)if(!d(a,b[c]))return!1;return!0}function f(a,b){var c=!0;return h(b,function(b,d){return g(a[d],b)?void 0:c=!1}),c}function g(a,b){return a&&"object"==typeof a?i(a)&&i(b)?e(a,b):f(a,b):a===b}var h=c(19),i=c(12);a.exports=g},function(a,b,c){function d(a){for(var b,c=0,d=arguments.length;++c<d;)b=arguments[c],null!=b&&f(b,e,a);return a}function e(a,b){this[b]=a}var f=c(19);a.exports=d}])});
!function(a,b){"object"==typeof exports&&"object"==typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):"object"==typeof exports?exports.Schemator=b():a.Schemator=b()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){var d=function(a){return a&&a.__esModule?a["default"]:a},e=function(){function a(a,b){for(var c in b){var d=b[c];d.configurable=!0,d.value&&(d.writable=!0)}Object.defineProperties(a,b)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),f=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")},g=d(c(1)),h=d(c(2)),i=d(c(3)),j=d(c(4)),k=1,l=function(){function a(){f(this,a),this.dataTypes={},this.rules={},this.schemata={},this.id=k++}return e(a,{availableDataTypes:{value:function(){return g.unique(g.keys(this.dataTypes).concat(g.keys(h)))}},availableRules:{value:function(){return g.unique(g.keys(this.rules).concat(g.keys(i)))}},availableSchemata:{value:function(){return g.keys(this.schemata)}},defineDataType:{value:function(a,b){if(!g.isString(a))throw new Error('"name" must be a string!');if(!g.isFunction(b))throw new Error('"typeDefinition" must be a function!');if(this.dataTypes[a])throw new Error("dataType already registered!");this.dataTypes[a]=b}},defineRule:{value:function(a,b,c){if(!g.isString(a))throw new Error('"name" must be a string!');if(!g.isFunction(b))throw new Error('"ruleFunc" must be a function!');if(this.rules[a])throw new Error("rule already registered!");this.rules[a]=b,this.rules[a].async=!!c}},defineSchema:{value:function(a,b){if(this.schemata[a])throw new Error("schema already registered!");if(b instanceof j)throw new Error("schema registered elsewhere!");return this.schemata[a]=new j(a,b,this),this.schemata[a].parent=this,this.schemata[a]}},getDataType:{value:function(a){return this.dataTypes[a]||h[a]}},getRule:{value:function(a){return this.rules[a]||i[a]}},getSchema:{value:function(a){return this.schemata[a]}},removeDataType:{value:function(a){delete this.dataTypes[a]}},removeRule:{value:function(a){delete this.rules[a]}},removeSchema:{value:function(a){delete this.schemata[a]}},schemaCheck:{value:function(a){if(!this.schemata[a])throw new Error("schema is not registered!")}},validateSync:{value:function(a,b,c){return this.schemaCheck(a),this.schemata[a].validateSync(b,c)}},validate:{value:function(a,b,c,d){return this.schemaCheck(a),this.schemata[a].validate(b,c,d)}},addDefaultsToTarget:{value:function(a,b,c){return this.schemaCheck(a),this.schemata[a].addDefaultsToTarget(b,c)}},setDefaults:{value:function(a,b){return this.schemaCheck(a),this.schemata[a].setDefaults(b)}},getDefaults:{value:function(a){return this.schemaCheck(a),this.schemata[a].getDefaults()}},stripNonSchemaAttrs:{value:function(a,b){return this.schemaCheck(a),this.schemata[a].stripNonSchemaAttrs(b)}}}),a}();a.exports=l},function(a,b,c){var d=function(a){return a&&a.__esModule?a["default"]:a},e=d(c(5)),f=d(c(6)),g=d(c(7)),h=d(c(8)),i=d(c(9)),j=d(c(10)),k=d(c(11)),l=d(c(12)),m=d(c(13)),n=d(c(14)),o=d(c(15)),p=d(c(16)),q=d(c(17)),r=d(c(18)),s=d(c(19)),t=d(c(20)),u=d(c(21)),v=d(c(22)),w=d(c(23)),x=d(c(24)),y=d(c(25)),z=d(c(26)),A=d(c(27)),B=d(c(28)),C=d(c(29)),D=d(c(30));a.exports={isString:e,isBoolean:f,isNumber:g,isObject:h,isDate:i,isFunction:j,isUndefined:k,isArray:l,isEmpty:m,toString:n,toNumber:o,get:p,deepMixIn:q,deepFillIn:r,forOwn:s,keys:t,pick:u,filter:v,map:w,merge:x,unset:y,contains:z,intersection:A,difference:B,unique:C,toInt:D,errMsg:function(a,b,c){return{rule:a,actual:b,expected:c}},parallel:function(a,b){function c(a){e+=1,(a||e>=f)&&b(a,d)}var d={},e=0,f=0;s(a,function(){f+=1}),s(a,function(a,b){a(function(a){var e=Array.prototype.slice.call(arguments,1);e.length<=1&&(e=e[0]),d[b]=e,c(a)})})}}},function(a,b,c){var d=function(a){return a&&a.__esModule?a["default"]:a},e=d(c(1));a.exports={string:function(a){return e.isString(a)?null:e.errMsg("type",typeof a,"string")},number:function(a){return e.isNumber(a)?null:e.errMsg("type",typeof a,"number")},integer:function(a){return e.isNumber(a)?Math.abs(a)-Math.abs(e.toInt(a))!==0?e.errMsg("type","real","integer"):null:e.errMsg("type",typeof a,"integer")},"float":function(a){return e.isNumber(a)?null:e.errMsg("type",typeof a,"float")},array:function(a){return e.isArray(a)?null:e.errMsg("type",typeof a,"array")},object:function(a){return e.isObject(a)?null:e.errMsg("type",typeof a,"object")},"boolean":function(a){return e.isBoolean(a)?null:e.errMsg("type",typeof a,"boolean")},date:function(a){return e.isDate(a)?null:e.errMsg("type",typeof a,"date")}}},function(a,b,c){var d=function(a){return a&&a.__esModule?a["default"]:a},e=d(c(1)),f=d(c(2));a.exports={nullable:function(a){var b=function(){return a.apply(this,arguments)};return b.toString=function(){return a.toString()},b}(function(a,b){return null!==a&&void 0!==a||b?null:e.errMsg("nullable","x === "+a,"x !== null && x !== undefined")}),max:function(a){var b=function(){return a.apply(this,arguments)};return b.toString=function(){return a.toString()},b}(function(a,b){return e.isNumber(a)&&e.isNumber(b)&&a>b?e.errMsg("max",""+a+" > "+b,""+a+" <= "+b):null}),min:function(a){var b=function(){return a.apply(this,arguments)};return b.toString=function(){return a.toString()},b}(function(a,b){return e.isNumber(a)&&e.isNumber(b)&&b>a?e.errMsg("min",""+a+" < "+b,""+a+" >= "+b):null}),maxLength:function(a){var b=function(){return a.apply(this,arguments)};return b.toString=function(){return a.toString()},b}(function(a,b){return(e.isString(a)||e.isArray(a))&&e.isNumber(b)&&a.length>b?e.errMsg("maxLength",""+a.length+" > "+b,""+a.length+" <= "+b):null}),minLength:function(a){var b=function(){return a.apply(this,arguments)};return b.toString=function(){return a.toString()},b}(function(a,b){return(e.isString(a)||e.isArray(a))&&e.isNumber(b)&&a.length<b?e.errMsg("minLength",""+a.length+" < "+b,""+a.length+" >= "+b):null}),type:function(a){var b=function(){return a.apply(this,arguments)};return b.toString=function(){return a.toString()},b}(function(a,b,c,d){return c?c(a):d.dataTypes[b]?d.dataTypes[b](a):f[b]?f[b](a):null})}},function(a,b,c){function d(a,b,c,d,f){var g=this,h=a+(a.length?".":"")+f,i=m.get(this.schema,h);if(m.isObject(d)||o(i)){var j=e.apply(this,[h,d,b]);j&&(c[f]=j)}else{if(!m.isObject(i))return;if(i.nullable===!0){var k=this.parent.rules.nullable||n.nullable,l=k.call(b.ctx,d,!0,void 0,this.parent);if(null===l)return}m.forOwn(i,function(a,e){var h=g.parent.rules[e]||n[e];if(h&&!h.async){var i=h.call(b.ctx,d,a,void 0,g.parent);i&&(c[f]||(c[f]={errors:[]}),c[f].errors.push(i))}})}}function e(a,b,c){var e=this,f={};try{if(m.forOwn(b,function(b,g){d.call(e,a,c,f,b,g)}),!c.ignoreMissing){var g=a?m.get(this.schema,a)||{}:this.schema,h=m.difference(m.keys(g),m.keys(b));h=m.pick(this.schema,h),h=m.map(h,function(){return void 0}),m.forOwn(h,function(b,g){d.call(e,a,c,f,b,g)})}return m.isEmpty(f)?null:f}catch(i){return i}}function f(a,b,c,d,e,f,h){var i=this,j=d+c,k=m.get(this.schema,j);if(m.isObject(b)||o(k))f[c]=function(b,c){return function(d){g.apply(i,[b,c,a,d])}}(j,b);else{if(!m.isObject(k))return;if(k.nullable===!0){var l=this.parent.rules.nullable||n.nullable,p=l.call(a.ctx,b,!0,void 0,this.parent);if(null===p)return}m.forOwn(k,function(d,f){var g=i.parent.rules[f]||n[f];if(g&&g.async)h[""+f+"_"+d]=function(b,c,d,e){return function(f){b.call(a.ctx,d,e,function(a){f(null,{err:a,key:c})})}}(g,c,b,d);else{var j=g.call(a.ctx,b,d,void 0,i.parent);j&&(e[c]||(e[c]={errors:[]}),e[c].errors.push(j))}})}}function g(a,b,c,d){var e=this,g={},h=a+(a.length?".":""),i={},j={},k=c.first;if(delete c.first,m.forOwn(b,function(a,b){f.call(e,c,a,b,h,g,i,j)}),!c.ignoreMissing){var l=a?m.get(this.schema,a)||{}:this.schema,n=m.difference(m.keys(l),m.keys(b));n=m.pick(this.schema,n),n=m.map(n,function(){return void 0}),m.forOwn(n,function(a,b){f.call(e,c,a,b,h,g,i,j)})}var o={};m.isEmpty(i)||(o.deepQueue=function(a){m.parallel(i,a)}),m.isEmpty(j)||(o.ruleQueue=function(a){m.parallel(j,a)}),m.isEmpty(o)?m.isEmpty(g)?d(null):k?d(g):d(null,g):m.parallel(o,function(a,b){b.deepQueue&&(b.deepQueue=m.filter(b.deepQueue,function(a){return void 0!==a&&null!==a}),m.deepMixIn(g,b.deepQueue)),b.ruleQueue&&(b.ruleQueue&&(b.ruleQueue=m.filter(b.ruleQueue,function(a){return void 0!==a.err&&null!==a.err})),m.forOwn(b.ruleQueue,function(a){g[a.key]||(g[a.key]={errors:[]}),g[a.key].errors.push(a.err)})),m.isEmpty(g)?d(null):k?d(g):d(null,g)})}function h(a,b){b=b||[];var c=m.keys(a),d=0===m.intersection(c,b).length;m.forOwn(a,function(c,e){if(d&&m.isString(c))a[e]={type:c};else if(m.isObject(c)){if(m.contains(b,e))throw new Error('Rule configuration for rule "'+e+'" cannot be an object!');h(c,b)}})}function i(a,b){m.forOwn(a,function(c,d){b[d]?m.isObject(c)&&m.isObject(b[d])&&i(c,b[d]):m.unset(a,d)})}var j=function(a){return a&&a.__esModule?a["default"]:a},k=function(){function a(a,b){for(var c in b){var d=b[c];d.configurable=!0,d.value&&(d.writable=!0)}Object.defineProperties(a,b)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),l=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")},m=j(c(1)),n=j(c(3)),o=function(a){var b=!1;return m.forOwn(a,function(a){return m.isObject(a)?(b=!0,!1):void 0}),b},p={a:"Schema#validateSync(attrs[, options]): ",b:"Schema#validate(attrs[, options], cb): "},q=function(){function a(b,c,d){if(l(this,a),!m.isString(b))throw new Error('"name" must be a string!');if(!m.isObject(c))throw new Error('"schema" must be an object!');this.name=b,h(c,d?d.availableRules():n),this.schema=c}return k(a,{validateSync:{value:function(a,b){if(b=b?b===!0?{ignoreMissing:!0}:b:{},!m.isObject(a))throw new Error(""+p.a+"attrs: Must be an object!");if(!m.isObject(b))throw new Error(""+p.a+"options: Must be an object!");return b.ctx=a,e.call(this,"",a,b)}},validate:{value:function(a,b,c){if(b=b?b===!0?{ignoreMissing:!0}:b:{},m.isFunction(b)&&(c=b,b={}),!m.isFunction(c))throw new Error(""+p.b+"cb: Must be a function!");return m.isObject(a)?m.isObject(b)?(b.first=!0,b.ctx=a,void g.call(this,"",a,b,c)):c(new Error(""+p.b+"options: Must be an object!")):c(new Error(""+p.b+"attrs: Must be an object!"))}},addDefaultsToTarget:{value:function(a,b){if(!m.isObject(a))throw new Error('"target" must be an object!');if(!this.defaults)throw new Error("No defaults have been set!");b?m.deepMixIn(a,this.defaults):m.deepFillIn(a,this.defaults)}},setDefaults:{value:function(a){if(!m.isObject(a))throw new Error("Schema#defaults(attrs): attrs: Must be an object!");return this.defaults=m.merge({},a),this}},getDefaults:{value:function(){return m.merge({},this.defaults)}},stripNonSchemaAttrs:{value:function(a){return i(a,this.schema),a}}}),a}();a.exports=q},function(a,b,c){function d(a){return e(a,"String")}var e=c(31);a.exports=d},function(a,b,c){function d(a){return e(a,"Boolean")}var e=c(31);a.exports=d},function(a,b,c){function d(a){return e(a,"Number")}var e=c(31);a.exports=d},function(a,b,c){function d(a){return e(a,"Object")}var e=c(31);a.exports=d},function(a,b,c){function d(a){return e(a,"Date")}var e=c(31);a.exports=d},function(a,b,c){function d(a){return e(a,"Function")}var e=c(31);a.exports=d},function(a){function b(a){return a===c}var c;a.exports=b},function(a,b,c){var d=c(31),e=Array.isArray||function(a){return d(a,"Array")};a.exports=e},function(a,b,c){function d(a){if(null==a)return!0;if("string"==typeof a||f(a))return!a.length;if("object"==typeof a){var b=!0;return e(a,function(){return b=!1,!1}),b}return!0}var e=c(19),f=c(12);a.exports=d},function(a){function b(a){return null==a?"":a.toString()}a.exports=b},function(a,b,c){function d(a){return"number"==typeof a?a:a?"string"==typeof a?parseFloat(a):e(a)?0/0:Number(a):0}var e=c(12);a.exports=d},function(a,b,c){function d(a,b){for(var c=b.split("."),d=c.pop();b=c.shift();)if(a=a[b],null==a)return;return a[d]}c(32);a.exports=d},function(a,b,c){function d(a){for(var b,c=0,d=arguments.length;++c<d;)b=arguments[c],b&&f(b,e,a);return a}function e(a,b){var c=this[b];g(a)&&g(c)?d(c,a):this[b]=a}var f=c(19),g=c(33);a.exports=d},function(a,b,c){function d(a){for(var b,c=0,g=arguments.length;++c<g;)b=arguments[c],b&&e(b,function(b,c){var e=a[c];null==e?a[c]=b:f(e)&&f(b)&&d(e,b)});return a}var e=c(19),f=c(33);a.exports=d},function(a,b,c){function d(a,b,c){f(a,function(d,f){return e(a,f)?b.call(c,a[f],f,a):void 0})}var e=c(34),f=c(35);a.exports=d},function(a,b,c){var d=c(19),e=Object.keys||function(a){var b=[];return d(a,function(a,c){b.push(c)}),b};a.exports=e},function(a,b,c){function d(a){for(var b,c="string"!=typeof arguments[1]?arguments[1]:e(arguments,1),d={},f=0;b=c[f++];)d[b]=a[b];return d}var e=c(36);a.exports=d},function(a,b,c){function d(a,b,c){b=f(b,c);var d={};return e(a,function(a,c,e){b(a,c,e)&&(d[c]=a)}),d}var e=c(19),f=c(37);a.exports=d},function(a,b,c){function d(a,b,c){b=f(b,c);var d={};return e(a,function(a,c,e){d[c]=b(a,c,e)}),d}var e=c(19),f=c(37);a.exports=d},function(a,b,c){function d(){var a,b,c,h,i=1;for(h=f(arguments[0]);c=arguments[i++];)for(a in c)e(c,a)&&(b=c[a],h[a]=g(b)&&g(h[a])?d(h[a],b):f(b));return h}var e=c(34),f=c(38),g=c(8);a.exports=d},function(a,b,c){function d(a,b){if(e(a,b)){for(var c=b.split("."),d=c.pop();b=c.shift();)a=a[b];return delete a[d]}return!0}var e=c(39);a.exports=d},function(a,b,c){function d(a,b){return-1!==e(a,b)}var e=c(40);a.exports=d},function(a,b,c){function d(a){var b=i(arguments,1),c=f(e(a),function(a){return g(b,function(b){return h(b,a)})});return c}var e=c(29),f=c(41),g=c(42),h=c(26),i=c(36);a.exports=d},function(a,b,c){function d(a){var b=i(arguments,1),c=f(e(a),function(a){return!g(b,function(b){return h(b,a)})});return c}var e=c(29),f=c(41),g=c(43),h=c(26),i=c(36);a.exports=d},function(a,b,c){function d(a,b){return b=b||e,f(a,function(a,c,d){for(var e=d.length;++c<e;)if(b(a,d[c]))return!1;return!0})}function e(a,b){return a===b}var f=c(41);a.exports=d},function(a){function b(a){return~~a}a.exports=b},function(a,b,c){function d(a,b){return e(a)===b}var e=c(44);a.exports=d},function(a){function b(a){switch(typeof a){case"string":case"number":case"boolean":return!0}return null==a}a.exports=b},function(a){function b(a){return!!a&&"object"==typeof a&&a.constructor===Object}a.exports=b},function(a){function b(a,b){return Object.prototype.hasOwnProperty.call(a,b)}a.exports=b},function(a,b,c){function d(){h=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],g=!0;for(var a in{toString:null})g=!1}function e(a,b,c){var e,j=0;null==g&&d();for(e in a)if(f(b,a,e,c)===!1)break;if(g)for(var k=a.constructor,l=!!k&&a===k.prototype;(e=h[j++])&&("constructor"===e&&(l||!i(a,e))||a[e]===Object.prototype[e]||f(b,a,e,c)!==!1););}function f(a,b,c,d){return a.call(d,b[c],c,b)}var g,h,i=c(34);a.exports=e},function(a){function b(a,b,c){var d=a.length;b=null==b?0:0>b?Math.max(d+b,0):Math.min(b,d),c=null==c?d:0>c?Math.max(d+c,0):Math.min(c,d);for(var e=[];c>b;)e.push(a[b++]);return e}a.exports=b},function(a,b,c){function d(a,b){if(null==a)return e;switch(typeof a){case"function":return"undefined"!=typeof b?function(c,d,e){return a.call(b,c,d,e)}:a;case"object":return function(b){return g(b,a)};case"string":case"number":return f(a)}}var e=c(45),f=c(46),g=c(47);a.exports=d},function(a,b,c){function d(a,b){switch(i(a)){case"Object":return e(a,b);case"Array":return f(a,b);default:return g(a)}}function e(a,b){if(j(a)){var c={};return h(a,function(a,c){this[c]=d(a,b)},c),c}return b?b(a):a}function f(a,b){for(var c=[],e=-1,f=a.length;++e<f;)c[e]=d(a[e],b);return c}var g=c(48),h=c(19),i=c(44),j=c(33);a.exports=d},function(a,b,c){function d(a,b){return f(a,b)!==e}var e,f=c(16);a.exports=d},function(a){function b(a,b,c){if(c=c||0,null==a)return-1;for(var d=a.length,e=0>c?d+c:c;d>e;){if(a[e]===b)return e;e++}return-1}a.exports=b},function(a,b,c){function d(a,b,c){b=e(b,c);var d=[];if(null==a)return d;for(var f,g=-1,h=a.length;++g<h;)f=a[g],b(f,g,a)&&d.push(f);return d}var e=c(37);a.exports=d},function(a,b,c){function d(a,b,c){b=e(b,c);var d=!0;if(null==a)return d;for(var f=-1,g=a.length;++f<g;)if(!b(a[f],f,a)){d=!1;break}return d}var e=c(37);a.exports=d},function(a,b,c){function d(a,b,c){b=e(b,c);var d=!1;if(null==a)return d;for(var f=-1,g=a.length;++f<g;)if(b(a[f],f,a)){d=!0;break}return d}var e=c(37);a.exports=d},function(a){function b(a){return null===a?"Null":a===c?"Undefined":d.exec(e.call(a))[1]}var c,d=/^\[object (.*)\]$/,e=Object.prototype.toString;a.exports=b},function(a){function b(a){return a}a.exports=b},function(a){function b(a){return function(b){return b[a]}}a.exports=b},function(a,b,c){function d(a,b){for(var c=-1,d=a.length;++c<d;)if(g(a[c],b))return!0;return!1}function e(a,b){for(var c=-1,e=b.length;++c<e;)if(!d(a,b[c]))return!1;return!0}function f(a,b){var c=!0;return h(b,function(b,d){return g(a[d],b)?void 0:c=!1}),c}function g(a,b){return a&&"object"==typeof a?i(a)&&i(b)?e(a,b):f(a,b):a===b}var h=c(19),i=c(12);a.exports=g},function(a,b,c){function d(a){switch(i(a)){case"Object":return e(a);case"Array":return h(a);case"RegExp":return f(a);case"Date":return g(a);default:return a}}function e(a){return j(a)?k({},a):a}function f(a){var b="";return b+=a.multiline?"m":"",b+=a.global?"g":"",b+=a.ignoreCase?"i":"",new RegExp(a.source,b)}function g(a){return new Date(+a)}function h(a){return a.slice()}var i=c(44),j=c(33),k=c(49);a.exports=d},function(a,b,c){function d(a){for(var b,c=0,d=arguments.length;++c<d;)b=arguments[c],null!=b&&f(b,e,a);return a}function e(a,b){this[b]=a}var f=c(19);a.exports=d}])});
//# sourceMappingURL=js-data-schema.min.map

@@ -5,6 +5,18 @@ /*jshint latedef:false*/

let hasObject = v => {
var has = false;
utils.forOwn(v, _v => {
if (utils.isObject(_v)) {
has = true;
return false;
}
});
return has;
};
function _executeRulesSync(targetKey, options, errors, value, key) {
let nestedKey = targetKey + (targetKey.length ? '.' : '') + key;
let schemaRules = utils.get(this.schema, nestedKey);
if (utils.isObject(value)) {
if (utils.isObject(value) || hasObject(schemaRules)) {
let err = _validateSync.apply(this, [nestedKey, value, options]);

@@ -15,3 +27,2 @@ if (err) {

} else {
let schemaRules = utils.get(this.schema, nestedKey);
if (!utils.isObject(schemaRules)) {

@@ -29,3 +40,3 @@ return;

let rule = this.parent.rules[ruleKey] || defaultRules[ruleKey];
if (!rule.async) {
if (rule && !rule.async) {
let err = rule.call(options.ctx, value, ruleValue, undefined, this.parent);

@@ -78,4 +89,5 @@ if (err) {

let nestedKey = prefix + key;
let schemaRules = utils.get(this.schema, nestedKey);
if (utils.isObject(value)) {
if (utils.isObject(value) || hasObject(schemaRules)) {
// Recurse down into nested attributes

@@ -88,3 +100,2 @@ deepQueue[key] = ((nK, val) => {

} else {
let schemaRules = utils.get(this.schema, nestedKey);
if (!utils.isObject(schemaRules)) {

@@ -103,3 +114,3 @@ return;

// Asynchronous rules get added to the queue
if (rule.async) {
if (rule && rule.async) {
ruleQueue[`${ruleKey}_${ruleValue}`] = ((r, key, val, rVal) => {

@@ -106,0 +117,0 @@ return next => {

{
"name": "js-data-schema",
"description": "Define and validate rules, datatypes and schemata in Node and in the browser.",
"version": "1.2.1",
"version": "1.2.2",
"homepage": "http://www.js-data.io/docs/js-data-schema",

@@ -6,0 +6,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc