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

jsen

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsen - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

test/greedy.js

6

bower.json

@@ -24,2 +24,3 @@ {

"**/*.log",
"lib",
"node_modules",

@@ -29,4 +30,7 @@ "bower_components",

"test",
"tests"
"tests",
"*.md",
"*.json",
"index.js"
]
}
## Changelog
### v0.5.0
* Add greedy mode (#32, #33)
### v0.4.1

@@ -4,0 +8,0 @@

8

dist/jsen.js

@@ -987,4 +987,4 @@ /*

if (!noFailFast) {
code('return false');
if (!noFailFast && !options.greedy) {
code('return (validate.errors = errors) && false');
}

@@ -1069,7 +1069,7 @@ }

var code = func('validate', 'data')
('var errors = validate.errors = []');
('var errors = []');
validate('data', schema);
code('return errors.length === 0');
code('return (validate.errors = errors) && errors.length === 0');

@@ -1076,0 +1076,0 @@ compiled = code.compile(scope);

@@ -9,2 +9,2 @@ /*

!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.jsen=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){b.exports=a("./lib/jsen.js")},{"./lib/jsen.js":5}],2:[function(a,b,c){"use strict";function d(a){var b=Object.prototype.toString.call(a);return b.substr(8,b.length-9).toLowerCase()}function e(a,b){var c,d,e=Object.keys(a).sort(),g=Object.keys(b).sort();if(!f(e,g))return!1;for(c=0;c<e.length;c++)if(d=e[c],!f(a[d],b[d]))return!1;return!0}function f(a,b){var c,g=typeof a,h=typeof b;if("object"===g&&(g=d(a)),"object"===h&&(h=d(b)),g!==h)return!1;if("object"===g)return e(a,b);if("regexp"===g)return a.toString()===b.toString();if("array"===g){if(a.length!==b.length)return!1;for(c=0;c<a.length;c++)if(!f(a[c],b[c]))return!1;return!0}return a===b}b.exports=f},{}],3:[function(a,b,c){"use strict";var d={};d["date-time"]=/(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)(:)?(\d\d)(\.\d+)?(Z|([+-])(\d\d)(:)?(\d\d))/,d.uri=/^([a-zA-Z][a-zA-Z0-9+-.]*:){0,1}\/\/[^\s]*$/,d.email=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,d.ipv4=/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,d.ipv6=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|[fF][eE]80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::([fF]{4}(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,d.hostname=/^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]))*$/,b.exports=d},{}],4:[function(a,b,c){"use strict";b.exports=function(){var a=arguments[0]||"",b=[].join.call([].slice.call(arguments,1),", "),c="",d="",e=1,f=" ",g="{[",h="}]",i=function(){return new Array(e+1).join(f)},j=function(a){c+=i()+a+"\n"},k=function(a){var b=a[0],c=a[a.length-1];return h.indexOf(b)>-1&&g.indexOf(c)>-1?(e--,j(a),e++):g.indexOf(c)>-1?(j(a),e++):h.indexOf(b)>-1?(e--,j(a)):j(a),k};return k.def=function(a,b){return d+=i()+"var "+a+(void 0!==b?" = "+b:"")+"\n",k},k.toSource=function(){return"function "+a+"("+b+") {\n"+d+"\n"+c+"\n}"},k.compile=function(a){var b="return ("+k.toSource()+")",c=a||{},d=Object.keys(c),e=d.map(function(a){return c[a]});return Function.apply(null,d.concat(b)).apply(null,e)},k}},{}],5:[function(a,b,c){"use strict";function d(a){var b=a instanceof RegExp?a.toString():new RegExp(a).toString();return s?b:(b=b.substr(1,b.length-2),b="/"+b.replace(p,"\\$&")+"/")}function e(a,b){return q.lastIndex=0,q.test(b)?a+"."+b:a+'["'+b+'"]'}function f(a){var b=Object.prototype.toString.call(a);return b.substr(8,b.length-9).toLowerCase()}function g(a){return(0|a)===a}function h(a){var b,c,d=Object.keys(a),e=[],f={};for(c=0;c<d.length;c++)b=z[d[c]],b&&(b.type?(f[b.type]||(f[b.type]=[]),f[b.type].push(b)):e.push(b));return e.concat(Object.keys(f).reduce(function(a,b){return a.concat(f[b])},[]))}function i(a){var b=a.replace(o,"$1");return isNaN(+b)?'"'===b[0]?'[\\"'+b.substr(1,b.length-2)+'\\"]':'." + '+b+' + "':"."+b}function j(a){return'"'+a.replace(n,i).substr(5)+'"'}function k(a){var b,c,d=a,e=f(a);if("object"===e){d={};for(b in a)d[b]=k(a[b])}else if("array"===e)for(d=[],c=0;c<a.length;c++)d[c]=k(a[c]);else{if("regexp"===e)return new RegExp(a);if("date"===e)return new Date(a.toJSON())}return d}function l(a,b,c,d){var e,g,h,i;if("object"!==f(a))return b;if(a=d.resolve(a),void 0===b&&a.hasOwnProperty("default")&&(b=k(a["default"])),e=f(b),"object"===e&&"object"===f(a.properties)){for(h in a.properties)g=l(a.properties[h],b[h],c,d),void 0!==g&&(b[h]=g);for(h in b)h in a.properties||a.additionalProperties!==!1&&(c!==!1||a.additionalProperties)||delete b[h]}else if("array"===e&&a.items)if("array"===f(a.items))for(i=0;i<a.items.length;i++)g=l(a.items[i],b[i],c,d),(void 0!==g||i<b.length)&&(b[i]=g);else if(b.length)for(i=0;i<b.length;i++)b[i]=l(a.items,b[i],c,d);return b}function m(a,b){function c(a){var b,c=i.resolve(a),d=a.$ref,f=o[d];return f||(f=o[d]={key:n(),func:function(a){return b(a)}},b=e(c),Object.defineProperty(f.func,"errors",{get:function(){return b.errors}}),p[f.key]=f.func),"refs."+f.key}function e(a){function e(a){var b=n();return m.def(b,a),b}function f(a,g,i){function k(b,c){var d,e=a,f=c&&g.properties&&g.properties[c]&&g.properties[c].requiredMessage||g.invalidMessage;f||(f=c&&g.properties&&g.properties[c]&&g.properties[c].messages&&g.properties[c].messages[b]||g.messages&&g.messages[b]),a.indexOf("[")>-1?(e=j(a),c&&(e=e?e+' + ".'+c+'"':c),m("errors.push({")("path: "+e+", ")('keyword: "'+b+'"'+(f?",":"")),f&&m('message: "'+f+'"'),m("})")):(d=n(),e=e.substr(5),c&&(e=e?e+"."+c:c),p[d]={path:e,keyword:b},f&&(p[d].message=f),m("errors.push(refs."+d+")")),i||m("return false")}var l,o,r,s,t,u,v,w,x;if(void 0!==g.$ref)return o=c(g),r=j(a),s=e(0),void m("if (!"+o+"("+a+")) {")("if ("+o+".errors) {")("errors.push.apply(errors, "+o+".errors)")("for ("+s+" = 0; "+s+" < "+o+".errors.length; "+s+"++) {")("if ("+o+".errors["+s+"].path) {")("errors[errors.length - "+o+".errors.length + "+s+"].path = "+r+' + "." + '+o+".errors["+s+"].path")("} else {")("errors[errors.length - "+o+".errors.length + "+s+"].path = "+r)("}")("}")("}")("}");for(l={path:a,schema:g,code:m,declare:e,validate:f,error:k,noFailFast:i},v=h(g),x=0;x<v.length;x++)w=v[x],w.type&&t!==w.type&&(t&&m("}"),t=w.type,m("if ("+y[w.type](a)+") {")),w(l);t&&m("}"),g.format&&b.formats&&(u=b.formats[g.format],u&&("string"==typeof u||u instanceof RegExp?(m("if (!("+d(u)+").test("+l.path+")) {"),k("format"),m("}")):"function"==typeof u&&((q.formats||(q.formats={}))[g.format]=u,(q.schemas||(q.schemas={}))[g.format]=g,m('if (!formats["'+g.format+'"]('+l.path+', schemas["'+g.format+'"])) {'),k("format"),m("}"))))}var m=t("validate","data")("var errors = validate.errors = []");return f("data",a),m("return errors.length === 0"),g=m.compile(q),g.errors=[],g.build=function(b,c){return l(a,c&&c.copy===!1?b:k(b),c&&c.additionalProperties,i)},g}if("object"!==f(a))throw new Error(r);b=b||{};var g,i=new w(a,b.schemas),m=0,n=function(){return"i"+m++},o={},p={errors:[]},q={equal:u,unique:v,refs:p};return e(a)}var n=/\[.+?\]/g,o=/\[?(.*?)?\]/,p=/[\/]/g,q=/^[a-z_$][0-9a-z]*$/gi,r="jsen: invalid schema object",s="object"==typeof window&&!!window.navigator,t=a("./func.js"),u=a("./equal.js"),v=a("./unique.js"),w=a("./resolver.js"),x=a("./formats.js"),y={},z={};y["null"]=function(a){return a+" === null"},y["boolean"]=function(a){return"typeof "+a+' === "boolean"'},y.string=function(a){return"typeof "+a+' === "string"'},y.number=function(a){return"typeof "+a+' === "number"'},y.integer=function(a){return"typeof "+a+' === "number" && !('+a+" % 1)"},y.array=function(a){return a+" !== undefined && Array.isArray("+a+")"},y.object=function(a){return a+" !== undefined && typeof "+a+' === "object" && '+a+" !== null && !Array.isArray("+a+")"},y.date=function(a){return a+" !== undefined && "+a+" instanceof Date"},z.type=function(a){if(a.schema.type){var b=Array.isArray(a.schema.type)?a.schema.type:[a.schema.type],c=b.map(function(b){return y[b]?y[b](a.path)||"true":"true"}).join(" || ");c&&(a.code("if (!("+c+")) {"),a.error("type"),a.code("}"))}},z["enum"]=function(a){var b,c,d,e=a.schema["enum"],f=[];if(Array.isArray(e)){for(d=0;d<e.length;d++)b=e[d],c=typeof b,null===b||["boolean","number","string"].indexOf(c)>-1?"string"===c?f.push(a.path+' === "'+b+'"'):f.push(a.path+" === "+b):f.push("equal("+a.path+", "+JSON.stringify(b)+")");a.code("if (!("+f.join(" || ")+")) {"),a.error("enum"),a.code("}")}},z.minimum=function(a){"number"==typeof a.schema.minimum&&(a.code("if ("+a.path+" < "+a.schema.minimum+") {"),a.error("minimum"),a.code("}"))},z.exclusiveMinimum=function(a){a.schema.exclusiveMinimum===!0&&"number"==typeof a.schema.minimum&&(a.code("if ("+a.path+" === "+a.schema.minimum+") {"),a.error("exclusiveMinimum"),a.code("}"))},z.maximum=function(a){"number"==typeof a.schema.maximum&&(a.code("if ("+a.path+" > "+a.schema.maximum+") {"),a.error("maximum"),a.code("}"))},z.exclusiveMaximum=function(a){a.schema.exclusiveMaximum===!0&&"number"==typeof a.schema.maximum&&(a.code("if ("+a.path+" === "+a.schema.maximum+") {"),a.error("exclusiveMaximum"),a.code("}"))},z.multipleOf=function(a){if("number"==typeof a.schema.multipleOf){var b=a.schema.multipleOf,c=b.toString().length-b.toFixed(0).length-1,d=c>0?Math.pow(10,c):1,e=a.path;c>0?a.code("if (+(Math.round(("+e+" * "+d+') + "e+" + '+c+') + "e-" + '+c+") % "+b*d+" !== 0) {"):a.code("if ((("+e+" * "+d+") % "+b*d+") !== 0) {"),a.error("multipleOf"),a.code("}")}},z.minLength=function(a){g(a.schema.minLength)&&(a.code("if ("+a.path+".length < "+a.schema.minLength+") {"),a.error("minLength"),a.code("}"))},z.maxLength=function(a){g(a.schema.maxLength)&&(a.code("if ("+a.path+".length > "+a.schema.maxLength+") {"),a.error("maxLength"),a.code("}"))},z.pattern=function(a){var b="string"==typeof a.schema.pattern?new RegExp(a.schema.pattern):a.schema.pattern;"regexp"===f(b)&&(a.code("if (!("+d(b)+").test("+a.path+")) {"),a.error("pattern"),a.code("}"))},z.format=function(a){"string"==typeof a.schema.format&&x[a.schema.format]&&(a.code("if (!("+x[a.schema.format]+").test("+a.path+")) {"),a.error("format"),a.code("}"))},z.minItems=function(a){g(a.schema.minItems)&&(a.code("if ("+a.path+".length < "+a.schema.minItems+") {"),a.error("minItems"),a.code("}"))},z.maxItems=function(a){g(a.schema.maxItems)&&(a.code("if ("+a.path+".length > "+a.schema.maxItems+") {"),a.error("maxItems"),a.code("}"))},z.additionalItems=function(a){a.schema.additionalItems===!1&&Array.isArray(a.schema.items)&&(a.code("if ("+a.path+".length > "+a.schema.items.length+") {"),a.error("additionalItems"),a.code("}"))},z.uniqueItems=function(a){a.schema.uniqueItems&&(a.code("if (unique("+a.path+").length !== "+a.path+".length) {"),a.error("uniqueItems"),a.code("}"))},z.items=function(a){var b=a.declare(0),c=0;if("object"===f(a.schema.items))a.code("for ("+b+"; "+b+" < "+a.path+".length; "+b+"++) {"),a.validate(a.path+"["+b+"]",a.schema.items,a.noFailFast),a.code("}");else if(Array.isArray(a.schema.items)){for(;c<a.schema.items.length;c++)a.code("if ("+a.path+".length - 1 >= "+c+") {"),a.validate(a.path+"["+c+"]",a.schema.items[c],a.noFailFast),a.code("}");"object"===f(a.schema.additionalItems)&&(a.code("for ("+b+" = "+c+"; "+b+" < "+a.path+".length; "+b+"++) {"),a.validate(a.path+"["+b+"]",a.schema.additionalItems,a.noFailFast),a.code("}"))}},z.maxProperties=function(a){g(a.schema.maxProperties)&&(a.code("if (Object.keys("+a.path+").length > "+a.schema.maxProperties+") {"),a.error("maxProperties"),a.code("}"))},z.minProperties=function(a){g(a.schema.minProperties)&&(a.code("if (Object.keys("+a.path+").length < "+a.schema.minProperties+") {"),a.error("minProperties"),a.code("}"))},z.required=function(a){if(Array.isArray(a.schema.required))for(var b=0;b<a.schema.required.length;b++)a.code("if ("+e(a.path,a.schema.required[b])+" === undefined) {"),a.error("required",a.schema.required[b]),a.code("}")},z.properties=function(a){if(!a.validatedProperties){var b,c,d,g=a.schema.properties,h="object"===f(g)?Object.keys(g):[],i=a.schema.patternProperties,j="object"===f(i)?Object.keys(i):[],k=a.schema.additionalProperties,l=k===!1||"object"===f(k);if(h.length&&!j.length&&!l){for(c=0;c<h.length;c++)b=h[c],d=e(a.path,b),a.code("if ("+d+" !== undefined) {"),a.validate(d,g[b],a.noFailFast),a.code("}");a.validatedProperties=!0}}},z.patternProperties=z.additionalProperties=function(a){if(!a.validatedProperties){var b,c,g,h,i,j,k,l=a.schema.properties,m="object"===f(l)?Object.keys(l):[],n=a.schema.patternProperties,o="object"===f(n)?Object.keys(n):[],p=a.schema.additionalProperties,q=p===!1||"object"===f(p);if(m.length||o.length||q){for(b=a.declare("[]"),c=a.declare('""'),g=a.declare(0),q&&(h=a.declare(!1)),a.code(b+" = Object.keys("+a.path+")"),a.code("for ("+g+"; "+g+" < "+b+".length; "+g+"++) {")(c+" = "+b+"["+g+"]")("if ("+a.path+"["+c+"] === undefined) {")("continue")("}"),q&&a.code(h+" = false"),k=0;k<m.length;k++)i=m[k],a.code("if ("+c+' === "'+i+'") {'),q&&a.code(h+" = true"),a.validate(e(a.path,i),l[i],a.noFailFast),a.code("}");for(k=0;k<o.length;k++)j=o[k],a.code("if (("+d(j)+").test("+c+")) {"),q&&a.code(h+" = true"),a.validate(a.path+"["+c+"]",n[j],a.noFailFast),a.code("}");q&&(a.code("if (!"+h+") {"),p===!1?a.error("additionalProperties"):a.validate(a.path+"["+c+"]",p,a.noFailFast),a.code("}")),a.code("}"),a.validatedProperties=!0}}},z.dependencies=function(a){if("object"===f(a.schema.dependencies)){var b,c,d=0;for(b in a.schema.dependencies){if(c=a.schema.dependencies[b],a.code("if ("+e(a.path,b)+" !== undefined) {"),"object"===f(c))a.validate(a.path,c,a.noFailFast);else for(d;d<c.length;d++)a.code("if ("+e(a.path,c[d])+" === undefined) {"),a.error("dependencies",c[d]),a.code("}");a.code("}")}}},z.allOf=function(a){if(Array.isArray(a.schema.allOf))for(var b=0;b<a.schema.allOf.length;b++)a.validate(a.path,a.schema.allOf[b],a.noFailFast)},z.anyOf=function(a){if(Array.isArray(a.schema.anyOf)){var b=a.declare(0),c=a.declare(0),d=a.declare(!1),e=0;for(a.code(c+" = errors.length");e<a.schema.anyOf.length;e++)a.code("if (!"+d+") {"),a.code(b+" = errors.length"),a.validate(a.path,a.schema.anyOf[e],!0),a.code(d+" = errors.length === "+b)("}");a.code("if (!"+d+") {"),a.error("anyOf"),a.code("} else {")("errors.length = "+c)("}")}},z.oneOf=function(a){if(Array.isArray(a.schema.oneOf)){var b=a.declare(0),c=a.declare(0),d=a.declare(0),e=0;for(a.code(c+" = errors.length");e<a.schema.oneOf.length;e++)a.code(d+" = errors.length"),a.validate(a.path,a.schema.oneOf[e],!0),a.code("if (errors.length === "+d+") {")(b+"++")("}");a.code("if ("+b+" !== 1) {"),a.error("oneOf"),a.code("} else {")("errors.length = "+c)("}")}},z.not=function(a){if("object"===f(a.schema.not)){var b=a.declare(0);a.code(b+" = errors.length"),a.validate(a.path,a.schema.not,!0),a.code("if (errors.length === "+b+") {"),a.error("not"),a.code("} else {")("errors.length = "+b)("}")}},["minimum","exclusiveMinimum","maximum","exclusiveMaximum","multipleOf"].forEach(function(a){z[a].type="number"}),["minLength","maxLength","pattern","format"].forEach(function(a){z[a].type="string"}),["minItems","maxItems","additionalItems","uniqueItems","items"].forEach(function(a){z[a].type="array"}),["maxProperties","minProperties","required","properties","patternProperties","additionalProperties","dependencies"].forEach(function(a){z[a].type="object"}),m.browser=s,m.clone=k,m.equal=u,m.unique=v,b.exports=m},{"./equal.js":2,"./formats.js":3,"./func.js":4,"./resolver.js":7,"./unique.js":8}],6:[function(a,b,c){b.exports={id:"http://json-schema.org/draft-04/schema#",$schema:"http://json-schema.org/draft-04/schema#",description:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},positiveInteger:{type:"integer",minimum:0},positiveIntegerDefault0:{allOf:[{$ref:"#/definitions/positiveInteger"},{"default":0}]},simpleTypes:{anyOf:[{"enum":["array","boolean","integer","null","number","object","string","any"]},{type:"string"}]},stringArray:{type:"array",items:{type:"string"},minItems:1,uniqueItems:!0}},type:"object",properties:{id:{type:"string",format:"uri"},$schema:{type:"string",format:"uri"},title:{type:"string"},description:{type:"string"},"default":{},multipleOf:{type:"number",minimum:0,exclusiveMinimum:!0},maximum:{type:"number"},exclusiveMaximum:{type:"boolean","default":!1},minimum:{type:"number"},exclusiveMinimum:{type:"boolean","default":!1},maxLength:{$ref:"#/definitions/positiveInteger"},minLength:{$ref:"#/definitions/positiveIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{anyOf:[{type:"boolean"},{$ref:"#"}],"default":{}},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],"default":{}},maxItems:{$ref:"#/definitions/positiveInteger"},minItems:{$ref:"#/definitions/positiveIntegerDefault0"},uniqueItems:{type:"boolean","default":!1},maxProperties:{$ref:"#/definitions/positiveInteger"},minProperties:{$ref:"#/definitions/positiveIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{anyOf:[{type:"boolean"},{$ref:"#"}],"default":{}},definitions:{type:"object",additionalProperties:{$ref:"#"},"default":{}},properties:{type:"object",additionalProperties:{$ref:"#"},"default":{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},"default":{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},"enum":{type:"array",minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},dependencies:{exclusiveMaximum:["maximum"],exclusiveMinimum:["minimum"]},"default":{}}},{}],7:[function(a,b,c){"use strict";function d(a,b){var c,d,e=b.split(".");if(1===e.length)return a[b];for(;e.length&&void 0!==a&&null!==a;){for(d=e.slice(0),c=void 0;d.length&&void 0===c;)c=a[d.join(".")],void 0===c&&d.pop();if(void 0!==c)for(a=c;d.length;)d.shift(),e.shift();else a=a[e.shift()]}return a}function e(a){return decodeURIComponent(a).replace(/~1/g,"/").replace(/~0/g,"~")}function f(a){if(a.indexOf("#")<0)return a;var b=a.split("#")[1];return b&&(b=b.split("/").map(e).join("."),"."===b[0]&&(b=b.substr(1))),b}function g(a,b){return a&&"object"==typeof a?a.id===b?a:Object.keys(a).reduce(function(c,d){return c||g(a[d],b)},void 0):void 0}function h(a){var b,c,d=Object.keys(a),e={};for(c=0;c<d.length;c++)b=d[c],e[b]=new i(a[b]);return e}function i(a,b){this.rootSchema=a,this.cache={},this.resolved=null,this.resolvers=b&&"object"==typeof b?h(b):null}var j=a("./metaschema.json"),k=/#?(\/?\w+)*$/,l="jsen: invalid schema reference";i.prototype.resolveRef=function(a){var b,c,e,h=new Error(l+" "+a),i=this.rootSchema;if(!a||"string"!=typeof a||!k.test(a))throw h;if(a===j.id&&(e=j),e||(e=g(i,a)),e||(c=f(a),e=c?d(i,c):i),!e&&c&&this.resolvers&&(b=d(this.resolvers,c),b&&(e=b.resolve(b.rootSchema))),!e||"object"!=typeof e)throw h;return this.cache[a]===e?e:(this.cache[a]=e,void 0!==e.$ref&&(e=this.cache[a]=this.resolveRef(e.$ref)),e)},i.prototype.resolve=function(a){if(!a||"object"!=typeof a)return a;var b=a.$ref,c=this.cache[b];return void 0===b?a:c?c:(c=this.resolveRef(b),a===this.rootSchema&&a!==c&&(this.rootSchema=c),c)},b.exports=i},{"./metaschema.json":6}],8:[function(a,b,c){"use strict";function d(a,b,c){for(var d=0,e=a.length;e>d;d++)if(c(a[d],b))return d;return-1}var e=a("./equal.js");b.exports=function(a){return a.filter(function(a,b,c){return d(c,a,e)===b})},b.exports.findIndex=d},{"./equal.js":2}]},{},[1])(1)});
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.jsen=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){b.exports=a("./lib/jsen.js")},{"./lib/jsen.js":5}],2:[function(a,b,c){"use strict";function d(a){var b=Object.prototype.toString.call(a);return b.substr(8,b.length-9).toLowerCase()}function e(a,b){var c,d,e=Object.keys(a).sort(),g=Object.keys(b).sort();if(!f(e,g))return!1;for(c=0;c<e.length;c++)if(d=e[c],!f(a[d],b[d]))return!1;return!0}function f(a,b){var c,g=typeof a,h=typeof b;if("object"===g&&(g=d(a)),"object"===h&&(h=d(b)),g!==h)return!1;if("object"===g)return e(a,b);if("regexp"===g)return a.toString()===b.toString();if("array"===g){if(a.length!==b.length)return!1;for(c=0;c<a.length;c++)if(!f(a[c],b[c]))return!1;return!0}return a===b}b.exports=f},{}],3:[function(a,b,c){"use strict";var d={};d["date-time"]=/(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)(:)?(\d\d)(\.\d+)?(Z|([+-])(\d\d)(:)?(\d\d))/,d.uri=/^([a-zA-Z][a-zA-Z0-9+-.]*:){0,1}\/\/[^\s]*$/,d.email=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,d.ipv4=/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,d.ipv6=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|[fF][eE]80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::([fF]{4}(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,d.hostname=/^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]))*$/,b.exports=d},{}],4:[function(a,b,c){"use strict";b.exports=function(){var a=arguments[0]||"",b=[].join.call([].slice.call(arguments,1),", "),c="",d="",e=1,f=" ",g="{[",h="}]",i=function(){return new Array(e+1).join(f)},j=function(a){c+=i()+a+"\n"},k=function(a){var b=a[0],c=a[a.length-1];return h.indexOf(b)>-1&&g.indexOf(c)>-1?(e--,j(a),e++):g.indexOf(c)>-1?(j(a),e++):h.indexOf(b)>-1?(e--,j(a)):j(a),k};return k.def=function(a,b){return d+=i()+"var "+a+(void 0!==b?" = "+b:"")+"\n",k},k.toSource=function(){return"function "+a+"("+b+") {\n"+d+"\n"+c+"\n}"},k.compile=function(a){var b="return ("+k.toSource()+")",c=a||{},d=Object.keys(c),e=d.map(function(a){return c[a]});return Function.apply(null,d.concat(b)).apply(null,e)},k}},{}],5:[function(a,b,c){"use strict";function d(a){var b=a instanceof RegExp?a.toString():new RegExp(a).toString();return s?b:(b=b.substr(1,b.length-2),b="/"+b.replace(p,"\\$&")+"/")}function e(a,b){return q.lastIndex=0,q.test(b)?a+"."+b:a+'["'+b+'"]'}function f(a){var b=Object.prototype.toString.call(a);return b.substr(8,b.length-9).toLowerCase()}function g(a){return(0|a)===a}function h(a){var b,c,d=Object.keys(a),e=[],f={};for(c=0;c<d.length;c++)b=z[d[c]],b&&(b.type?(f[b.type]||(f[b.type]=[]),f[b.type].push(b)):e.push(b));return e.concat(Object.keys(f).reduce(function(a,b){return a.concat(f[b])},[]))}function i(a){var b=a.replace(o,"$1");return isNaN(+b)?'"'===b[0]?'[\\"'+b.substr(1,b.length-2)+'\\"]':'." + '+b+' + "':"."+b}function j(a){return'"'+a.replace(n,i).substr(5)+'"'}function k(a){var b,c,d=a,e=f(a);if("object"===e){d={};for(b in a)d[b]=k(a[b])}else if("array"===e)for(d=[],c=0;c<a.length;c++)d[c]=k(a[c]);else{if("regexp"===e)return new RegExp(a);if("date"===e)return new Date(a.toJSON())}return d}function l(a,b,c,d){var e,g,h,i;if("object"!==f(a))return b;if(a=d.resolve(a),void 0===b&&a.hasOwnProperty("default")&&(b=k(a["default"])),e=f(b),"object"===e&&"object"===f(a.properties)){for(h in a.properties)g=l(a.properties[h],b[h],c,d),void 0!==g&&(b[h]=g);for(h in b)h in a.properties||a.additionalProperties!==!1&&(c!==!1||a.additionalProperties)||delete b[h]}else if("array"===e&&a.items)if("array"===f(a.items))for(i=0;i<a.items.length;i++)g=l(a.items[i],b[i],c,d),(void 0!==g||i<b.length)&&(b[i]=g);else if(b.length)for(i=0;i<b.length;i++)b[i]=l(a.items,b[i],c,d);return b}function m(a,b){function c(a){var b,c=i.resolve(a),d=a.$ref,f=o[d];return f||(f=o[d]={key:n(),func:function(a){return b(a)}},b=e(c),Object.defineProperty(f.func,"errors",{get:function(){return b.errors}}),p[f.key]=f.func),"refs."+f.key}function e(a){function e(a){var b=n();return m.def(b,a),b}function f(a,g,i){function k(c,d){var e,f=a,h=d&&g.properties&&g.properties[d]&&g.properties[d].requiredMessage||g.invalidMessage;h||(h=d&&g.properties&&g.properties[d]&&g.properties[d].messages&&g.properties[d].messages[c]||g.messages&&g.messages[c]),a.indexOf("[")>-1?(f=j(a),d&&(f=f?f+' + ".'+d+'"':d),m("errors.push({")("path: "+f+", ")('keyword: "'+c+'"'+(h?",":"")),h&&m('message: "'+h+'"'),m("})")):(e=n(),f=f.substr(5),d&&(f=f?f+"."+d:d),p[e]={path:f,keyword:c},h&&(p[e].message=h),m("errors.push(refs."+e+")")),i||b.greedy||m("return (validate.errors = errors) && false")}var l,o,r,s,t,u,v,w,x;if(void 0!==g.$ref)return o=c(g),r=j(a),s=e(0),void m("if (!"+o+"("+a+")) {")("if ("+o+".errors) {")("errors.push.apply(errors, "+o+".errors)")("for ("+s+" = 0; "+s+" < "+o+".errors.length; "+s+"++) {")("if ("+o+".errors["+s+"].path) {")("errors[errors.length - "+o+".errors.length + "+s+"].path = "+r+' + "." + '+o+".errors["+s+"].path")("} else {")("errors[errors.length - "+o+".errors.length + "+s+"].path = "+r)("}")("}")("}")("}");for(l={path:a,schema:g,code:m,declare:e,validate:f,error:k,noFailFast:i},v=h(g),x=0;x<v.length;x++)w=v[x],w.type&&t!==w.type&&(t&&m("}"),t=w.type,m("if ("+y[w.type](a)+") {")),w(l);t&&m("}"),g.format&&b.formats&&(u=b.formats[g.format],u&&("string"==typeof u||u instanceof RegExp?(m("if (!("+d(u)+").test("+l.path+")) {"),k("format"),m("}")):"function"==typeof u&&((q.formats||(q.formats={}))[g.format]=u,(q.schemas||(q.schemas={}))[g.format]=g,m('if (!formats["'+g.format+'"]('+l.path+', schemas["'+g.format+'"])) {'),k("format"),m("}"))))}var m=t("validate","data")("var errors = []");return f("data",a),m("return (validate.errors = errors) && errors.length === 0"),g=m.compile(q),g.errors=[],g.build=function(b,c){return l(a,c&&c.copy===!1?b:k(b),c&&c.additionalProperties,i)},g}if("object"!==f(a))throw new Error(r);b=b||{};var g,i=new w(a,b.schemas),m=0,n=function(){return"i"+m++},o={},p={errors:[]},q={equal:u,unique:v,refs:p};return e(a)}var n=/\[.+?\]/g,o=/\[?(.*?)?\]/,p=/[\/]/g,q=/^[a-z_$][0-9a-z]*$/gi,r="jsen: invalid schema object",s="object"==typeof window&&!!window.navigator,t=a("./func.js"),u=a("./equal.js"),v=a("./unique.js"),w=a("./resolver.js"),x=a("./formats.js"),y={},z={};y["null"]=function(a){return a+" === null"},y["boolean"]=function(a){return"typeof "+a+' === "boolean"'},y.string=function(a){return"typeof "+a+' === "string"'},y.number=function(a){return"typeof "+a+' === "number"'},y.integer=function(a){return"typeof "+a+' === "number" && !('+a+" % 1)"},y.array=function(a){return a+" !== undefined && Array.isArray("+a+")"},y.object=function(a){return a+" !== undefined && typeof "+a+' === "object" && '+a+" !== null && !Array.isArray("+a+")"},y.date=function(a){return a+" !== undefined && "+a+" instanceof Date"},z.type=function(a){if(a.schema.type){var b=Array.isArray(a.schema.type)?a.schema.type:[a.schema.type],c=b.map(function(b){return y[b]?y[b](a.path)||"true":"true"}).join(" || ");c&&(a.code("if (!("+c+")) {"),a.error("type"),a.code("}"))}},z["enum"]=function(a){var b,c,d,e=a.schema["enum"],f=[];if(Array.isArray(e)){for(d=0;d<e.length;d++)b=e[d],c=typeof b,null===b||["boolean","number","string"].indexOf(c)>-1?"string"===c?f.push(a.path+' === "'+b+'"'):f.push(a.path+" === "+b):f.push("equal("+a.path+", "+JSON.stringify(b)+")");a.code("if (!("+f.join(" || ")+")) {"),a.error("enum"),a.code("}")}},z.minimum=function(a){"number"==typeof a.schema.minimum&&(a.code("if ("+a.path+" < "+a.schema.minimum+") {"),a.error("minimum"),a.code("}"))},z.exclusiveMinimum=function(a){a.schema.exclusiveMinimum===!0&&"number"==typeof a.schema.minimum&&(a.code("if ("+a.path+" === "+a.schema.minimum+") {"),a.error("exclusiveMinimum"),a.code("}"))},z.maximum=function(a){"number"==typeof a.schema.maximum&&(a.code("if ("+a.path+" > "+a.schema.maximum+") {"),a.error("maximum"),a.code("}"))},z.exclusiveMaximum=function(a){a.schema.exclusiveMaximum===!0&&"number"==typeof a.schema.maximum&&(a.code("if ("+a.path+" === "+a.schema.maximum+") {"),a.error("exclusiveMaximum"),a.code("}"))},z.multipleOf=function(a){if("number"==typeof a.schema.multipleOf){var b=a.schema.multipleOf,c=b.toString().length-b.toFixed(0).length-1,d=c>0?Math.pow(10,c):1,e=a.path;c>0?a.code("if (+(Math.round(("+e+" * "+d+') + "e+" + '+c+') + "e-" + '+c+") % "+b*d+" !== 0) {"):a.code("if ((("+e+" * "+d+") % "+b*d+") !== 0) {"),a.error("multipleOf"),a.code("}")}},z.minLength=function(a){g(a.schema.minLength)&&(a.code("if ("+a.path+".length < "+a.schema.minLength+") {"),a.error("minLength"),a.code("}"))},z.maxLength=function(a){g(a.schema.maxLength)&&(a.code("if ("+a.path+".length > "+a.schema.maxLength+") {"),a.error("maxLength"),a.code("}"))},z.pattern=function(a){var b="string"==typeof a.schema.pattern?new RegExp(a.schema.pattern):a.schema.pattern;"regexp"===f(b)&&(a.code("if (!("+d(b)+").test("+a.path+")) {"),a.error("pattern"),a.code("}"))},z.format=function(a){"string"==typeof a.schema.format&&x[a.schema.format]&&(a.code("if (!("+x[a.schema.format]+").test("+a.path+")) {"),a.error("format"),a.code("}"))},z.minItems=function(a){g(a.schema.minItems)&&(a.code("if ("+a.path+".length < "+a.schema.minItems+") {"),a.error("minItems"),a.code("}"))},z.maxItems=function(a){g(a.schema.maxItems)&&(a.code("if ("+a.path+".length > "+a.schema.maxItems+") {"),a.error("maxItems"),a.code("}"))},z.additionalItems=function(a){a.schema.additionalItems===!1&&Array.isArray(a.schema.items)&&(a.code("if ("+a.path+".length > "+a.schema.items.length+") {"),a.error("additionalItems"),a.code("}"))},z.uniqueItems=function(a){a.schema.uniqueItems&&(a.code("if (unique("+a.path+").length !== "+a.path+".length) {"),a.error("uniqueItems"),a.code("}"))},z.items=function(a){var b=a.declare(0),c=0;if("object"===f(a.schema.items))a.code("for ("+b+"; "+b+" < "+a.path+".length; "+b+"++) {"),a.validate(a.path+"["+b+"]",a.schema.items,a.noFailFast),a.code("}");else if(Array.isArray(a.schema.items)){for(;c<a.schema.items.length;c++)a.code("if ("+a.path+".length - 1 >= "+c+") {"),a.validate(a.path+"["+c+"]",a.schema.items[c],a.noFailFast),a.code("}");"object"===f(a.schema.additionalItems)&&(a.code("for ("+b+" = "+c+"; "+b+" < "+a.path+".length; "+b+"++) {"),a.validate(a.path+"["+b+"]",a.schema.additionalItems,a.noFailFast),a.code("}"))}},z.maxProperties=function(a){g(a.schema.maxProperties)&&(a.code("if (Object.keys("+a.path+").length > "+a.schema.maxProperties+") {"),a.error("maxProperties"),a.code("}"))},z.minProperties=function(a){g(a.schema.minProperties)&&(a.code("if (Object.keys("+a.path+").length < "+a.schema.minProperties+") {"),a.error("minProperties"),a.code("}"))},z.required=function(a){if(Array.isArray(a.schema.required))for(var b=0;b<a.schema.required.length;b++)a.code("if ("+e(a.path,a.schema.required[b])+" === undefined) {"),a.error("required",a.schema.required[b]),a.code("}")},z.properties=function(a){if(!a.validatedProperties){var b,c,d,g=a.schema.properties,h="object"===f(g)?Object.keys(g):[],i=a.schema.patternProperties,j="object"===f(i)?Object.keys(i):[],k=a.schema.additionalProperties,l=k===!1||"object"===f(k);if(h.length&&!j.length&&!l){for(c=0;c<h.length;c++)b=h[c],d=e(a.path,b),a.code("if ("+d+" !== undefined) {"),a.validate(d,g[b],a.noFailFast),a.code("}");a.validatedProperties=!0}}},z.patternProperties=z.additionalProperties=function(a){if(!a.validatedProperties){var b,c,g,h,i,j,k,l=a.schema.properties,m="object"===f(l)?Object.keys(l):[],n=a.schema.patternProperties,o="object"===f(n)?Object.keys(n):[],p=a.schema.additionalProperties,q=p===!1||"object"===f(p);if(m.length||o.length||q){for(b=a.declare("[]"),c=a.declare('""'),g=a.declare(0),q&&(h=a.declare(!1)),a.code(b+" = Object.keys("+a.path+")"),a.code("for ("+g+"; "+g+" < "+b+".length; "+g+"++) {")(c+" = "+b+"["+g+"]")("if ("+a.path+"["+c+"] === undefined) {")("continue")("}"),q&&a.code(h+" = false"),k=0;k<m.length;k++)i=m[k],a.code("if ("+c+' === "'+i+'") {'),q&&a.code(h+" = true"),a.validate(e(a.path,i),l[i],a.noFailFast),a.code("}");for(k=0;k<o.length;k++)j=o[k],a.code("if (("+d(j)+").test("+c+")) {"),q&&a.code(h+" = true"),a.validate(a.path+"["+c+"]",n[j],a.noFailFast),a.code("}");q&&(a.code("if (!"+h+") {"),p===!1?a.error("additionalProperties"):a.validate(a.path+"["+c+"]",p,a.noFailFast),a.code("}")),a.code("}"),a.validatedProperties=!0}}},z.dependencies=function(a){if("object"===f(a.schema.dependencies)){var b,c,d=0;for(b in a.schema.dependencies){if(c=a.schema.dependencies[b],a.code("if ("+e(a.path,b)+" !== undefined) {"),"object"===f(c))a.validate(a.path,c,a.noFailFast);else for(d;d<c.length;d++)a.code("if ("+e(a.path,c[d])+" === undefined) {"),a.error("dependencies",c[d]),a.code("}");a.code("}")}}},z.allOf=function(a){if(Array.isArray(a.schema.allOf))for(var b=0;b<a.schema.allOf.length;b++)a.validate(a.path,a.schema.allOf[b],a.noFailFast)},z.anyOf=function(a){if(Array.isArray(a.schema.anyOf)){var b=a.declare(0),c=a.declare(0),d=a.declare(!1),e=0;for(a.code(c+" = errors.length");e<a.schema.anyOf.length;e++)a.code("if (!"+d+") {"),a.code(b+" = errors.length"),a.validate(a.path,a.schema.anyOf[e],!0),a.code(d+" = errors.length === "+b)("}");a.code("if (!"+d+") {"),a.error("anyOf"),a.code("} else {")("errors.length = "+c)("}")}},z.oneOf=function(a){if(Array.isArray(a.schema.oneOf)){var b=a.declare(0),c=a.declare(0),d=a.declare(0),e=0;for(a.code(c+" = errors.length");e<a.schema.oneOf.length;e++)a.code(d+" = errors.length"),a.validate(a.path,a.schema.oneOf[e],!0),a.code("if (errors.length === "+d+") {")(b+"++")("}");a.code("if ("+b+" !== 1) {"),a.error("oneOf"),a.code("} else {")("errors.length = "+c)("}")}},z.not=function(a){if("object"===f(a.schema.not)){var b=a.declare(0);a.code(b+" = errors.length"),a.validate(a.path,a.schema.not,!0),a.code("if (errors.length === "+b+") {"),a.error("not"),a.code("} else {")("errors.length = "+b)("}")}},["minimum","exclusiveMinimum","maximum","exclusiveMaximum","multipleOf"].forEach(function(a){z[a].type="number"}),["minLength","maxLength","pattern","format"].forEach(function(a){z[a].type="string"}),["minItems","maxItems","additionalItems","uniqueItems","items"].forEach(function(a){z[a].type="array"}),["maxProperties","minProperties","required","properties","patternProperties","additionalProperties","dependencies"].forEach(function(a){z[a].type="object"}),m.browser=s,m.clone=k,m.equal=u,m.unique=v,b.exports=m},{"./equal.js":2,"./formats.js":3,"./func.js":4,"./resolver.js":7,"./unique.js":8}],6:[function(a,b,c){b.exports={id:"http://json-schema.org/draft-04/schema#",$schema:"http://json-schema.org/draft-04/schema#",description:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},positiveInteger:{type:"integer",minimum:0},positiveIntegerDefault0:{allOf:[{$ref:"#/definitions/positiveInteger"},{"default":0}]},simpleTypes:{anyOf:[{"enum":["array","boolean","integer","null","number","object","string","any"]},{type:"string"}]},stringArray:{type:"array",items:{type:"string"},minItems:1,uniqueItems:!0}},type:"object",properties:{id:{type:"string",format:"uri"},$schema:{type:"string",format:"uri"},title:{type:"string"},description:{type:"string"},"default":{},multipleOf:{type:"number",minimum:0,exclusiveMinimum:!0},maximum:{type:"number"},exclusiveMaximum:{type:"boolean","default":!1},minimum:{type:"number"},exclusiveMinimum:{type:"boolean","default":!1},maxLength:{$ref:"#/definitions/positiveInteger"},minLength:{$ref:"#/definitions/positiveIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{anyOf:[{type:"boolean"},{$ref:"#"}],"default":{}},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],"default":{}},maxItems:{$ref:"#/definitions/positiveInteger"},minItems:{$ref:"#/definitions/positiveIntegerDefault0"},uniqueItems:{type:"boolean","default":!1},maxProperties:{$ref:"#/definitions/positiveInteger"},minProperties:{$ref:"#/definitions/positiveIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{anyOf:[{type:"boolean"},{$ref:"#"}],"default":{}},definitions:{type:"object",additionalProperties:{$ref:"#"},"default":{}},properties:{type:"object",additionalProperties:{$ref:"#"},"default":{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},"default":{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},"enum":{type:"array",minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},dependencies:{exclusiveMaximum:["maximum"],exclusiveMinimum:["minimum"]},"default":{}}},{}],7:[function(a,b,c){"use strict";function d(a,b){var c,d,e=b.split(".");if(1===e.length)return a[b];for(;e.length&&void 0!==a&&null!==a;){for(d=e.slice(0),c=void 0;d.length&&void 0===c;)c=a[d.join(".")],void 0===c&&d.pop();if(void 0!==c)for(a=c;d.length;)d.shift(),e.shift();else a=a[e.shift()]}return a}function e(a){return decodeURIComponent(a).replace(/~1/g,"/").replace(/~0/g,"~")}function f(a){if(a.indexOf("#")<0)return a;var b=a.split("#")[1];return b&&(b=b.split("/").map(e).join("."),"."===b[0]&&(b=b.substr(1))),b}function g(a,b){return a&&"object"==typeof a?a.id===b?a:Object.keys(a).reduce(function(c,d){return c||g(a[d],b)},void 0):void 0}function h(a){var b,c,d=Object.keys(a),e={};for(c=0;c<d.length;c++)b=d[c],e[b]=new i(a[b]);return e}function i(a,b){this.rootSchema=a,this.cache={},this.resolved=null,this.resolvers=b&&"object"==typeof b?h(b):null}var j=a("./metaschema.json"),k=/#?(\/?\w+)*$/,l="jsen: invalid schema reference";i.prototype.resolveRef=function(a){var b,c,e,h=new Error(l+" "+a),i=this.rootSchema;if(!a||"string"!=typeof a||!k.test(a))throw h;if(a===j.id&&(e=j),e||(e=g(i,a)),e||(c=f(a),e=c?d(i,c):i),!e&&c&&this.resolvers&&(b=d(this.resolvers,c),b&&(e=b.resolve(b.rootSchema))),!e||"object"!=typeof e)throw h;return this.cache[a]===e?e:(this.cache[a]=e,void 0!==e.$ref&&(e=this.cache[a]=this.resolveRef(e.$ref)),e)},i.prototype.resolve=function(a){if(!a||"object"!=typeof a)return a;var b=a.$ref,c=this.cache[b];return void 0===b?a:c?c:(c=this.resolveRef(b),a===this.rootSchema&&a!==c&&(this.rootSchema=c),c)},b.exports=i},{"./metaschema.json":6}],8:[function(a,b,c){"use strict";function d(a,b,c){for(var d=0,e=a.length;e>d;d++)if(c(a[d],b))return d;return-1}var e=a("./equal.js");b.exports=function(a){return a.filter(function(a,b,c){return d(c,a,e)===b})},b.exports.findIndex=d},{"./equal.js":2}]},{},[1])(1)});

@@ -820,3 +820,3 @@ 'use strict';

if (!noFailFast) {
if (!noFailFast && !options.greedy) {
code('return (validate.errors = errors) && false');

@@ -823,0 +823,0 @@ }

{
"name": "jsen",
"version": "0.4.1",
"version": "0.5.0",
"description": "JSON-Schema validator built for speed",

@@ -5,0 +5,0 @@ "author": "Veli Pehlivanov <bugventure@gmail.com>",

@@ -23,2 +23,3 @@ JSEN

- [Custom Errors for Keywords](#custom-errors-for-keywords)
- [Greedy Validation](#greedy-validation)
- [Gathering Default Values](#gathering-default-values)

@@ -340,2 +341,43 @@ - [options.copy](#optionscopy)

### Greedy Validation
For performance, by default, JSEN returns the first encountered error and bails out any further execution.
With the `options.greedy` flag passed to the builder function, the compiled validator will try to validate as much as possible, providing more info in the `errors` array.
```javascript
var schema = {
type: 'object',
properties: {
firstName: {
type: 'string',
minLength: 1,
maxLength: 20
},
lastName: {
type: 'string',
minLength: 2,
maxLength: 50
},
age: {
type: 'number',
minimum: 18,
maximum: 100
}
},
required: ['firstName', 'lastName', 'age']
};
var validate = jsen(schema, { greedy: true }); // enable greedy validation
validate({ firstName: null, lastName: '' });
console.log(validate.errors);
/* Output:
[ { path: 'firstName', keyword: 'type' },
{ path: 'lastName', keyword: 'minLength' },
{ path: 'age', keyword: 'required' } ]
*/
```
## Gathering Default Values

@@ -452,4 +494,4 @@

```
//cdn.rawgit.com/bugventure/jsen/v0.4.1/dist/jsen.js
//cdn.rawgit.com/bugventure/jsen/v0.4.1/dist/jsen.min.js
//cdn.rawgit.com/bugventure/jsen/v0.5.0/dist/jsen.js
//cdn.rawgit.com/bugventure/jsen/v0.5.0/dist/jsen.min.js
```

@@ -456,0 +498,0 @@

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