From 3d5ad8dc898726eb962817ce17c400b023d3df0d Mon Sep 17 00:00:00 2001 From: Szymon Dzialowski Date: Tue, 23 May 2023 23:08:03 +0100 Subject: [PATCH] 0.0.116 --- dist/spvalidation.js | 2 +- dist/spvalidation.min.js | 2 +- package-lock.json | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/spvalidation.js b/dist/spvalidation.js index 29e8962..7c38b77 100644 --- a/dist/spvalidation.js +++ b/dist/spvalidation.js @@ -1472,7 +1472,7 @@ var connectAndSort = function connectAndSort(_ref) { value: v, constraints: allConstraints, context: context, - path: combine(name) + path: String(combine(name)) }); }); } else { diff --git a/dist/spvalidation.min.js b/dist/spvalidation.min.js index 878879f..943af2a 100644 --- a/dist/spvalidation.min.js +++ b/dist/spvalidation.min.js @@ -3,4 +3,4 @@ * @homepage https://github.com/stopsopa/validator * @license MIT */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.spvalidation=e():t.spvalidation=e()}(self,(()=>{return t={219:(t,e,o)=>{t.exports=o(559)},559:t=>{function e(t){return new Error("promiseall error: "+t)}t.exports=function(t){if(!Array.isArray(t))throw e("list is not an array");var o=t.length;if(0===o)return Promise.resolve([]);for(var r,i=!1,s=0,n=t.length;s{function e(){var t=Error.apply(this,arguments);t.name=this.name="ValidatorLogicError",this.stack=t.stack,this.message=t.message}e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,t.exports=e},569:(t,e,o)=>{"use strict";var r=o(588),i=function(t,e){r.apply(this,arguments),this.setExtra(e),this.setOptions(t)};(i.prototype=Object.create(r.prototype)).constructor=i,t.exports=i},614:(t,e,o)=>{"use strict";var r=o(228),i=o(759),s=o(588),n={message:"This value should be blank."},a=function(t,e){s.apply(this,arguments),this.setExtra(e),"string"==typeof t&&(t={message:t}),this.setOptions(Object.assign({},n,t))};(a.prototype=Object.create(s.prototype)).constructor=a,a.prototype.NOT_BLANK_ERROR="NOT_BLANK_ERROR",a.prototype.validate=function(t,e,o,r){var i=this.getOptions();return!a.prototype.logic(t)&&(e.buildViolation(i.message).atPath(o).setCode(a.prototype.NOT_BLANK_ERROR).setInvalidValue(t).addViolation(),r&&r.stop)?Promise.reject("stop Blank"):Promise.resolve("resolve Blank")},a.prototype.logic=function(t){var e=!1;switch(!0){case!t:case"0"===t:case i(t)&&0===t.length:case r(t)&&0===Object.keys(t).length:e=!0}return e},t.exports=a},787:(t,e,o)=>{"use strict";var r=o(588),i=function(t,e){if(r.apply(this,arguments),this.setExtra(e),"function"!=typeof t)throw new Error("Callback constraint first arg should be function");this.setOptions(t)};(i.prototype=Object.create(r.prototype)).constructor=i,i.prototype.validate=function(t,e,o,r){var i=this.getOptions();return Promise.resolve(i(t,e,o,r))},t.exports=i},796:(t,e,o)=>{"use strict";o(228);var r=o(759),i=o(588),s={message:"The value you selected is not a valid choice.",multipleMessage:"One or more of the given values is invalid.",minMessage:"You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices.",maxMessage:"You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices.",multiple:!1},n=function(t,e){if(i.apply(this,arguments),this.setExtra(e),r(t)&&(t={choices:t}),t=Object.assign({},s,t),!r(t.choices)||0===t.choices.length)throw new Error("Choice: choices have to be non empty list");this.setOptions(t)};(n.prototype=Object.create(i.prototype)).constructor=n,n.prototype.NO_SUCH_CHOICE_ERROR="NO_SUCH_CHOICE_ERROR",n.prototype.TOO_FEW_ERROR="TOO_FEW_ERROR",n.prototype.TOO_MANY_ERROR="TOO_MANY_ERROR";var a=function(t,e){return t&&t.stop?Promise.reject("stop Choice"+e):Promise.resolve("resolve Choice"+e)};n.prototype.validate=function(t,e,o,i){var s=this.getOptions();if(null===t)return Promise.resolve("Choice");if(s.multiple){if(r(t)){for(var l=t.length,p=0,c=l;ps.max)return e.buildViolation(s.maxMessage).atPath(o).setParameter("{{ limit }}",s.max).setPlural(1===s.max?0:1).setInvalidValue(t).setCode(n.prototype.TOO_MANY_ERROR).setExtra(i).addViolation(),a(i,3)}}else if(-1===s.choices.indexOf(t))return e.buildViolation(s.message).atPath(o).setParameter("{{ value }}",t).setInvalidValue(t).setCode(n.prototype.NO_SUCH_CHOICE_ERROR).setExtra(i).addViolation(),a(i,4);return Promise.resolve("Choice1")},t.exports=n},663:(t,e,o)=>{"use strict";var r=o(538),i=o(228),s=o(588),n=o(475),a=o(161),l=o(288),p=o(764),c=o(759),u=o(573),h={fields:{},allowExtraFields:!1,allowMissingFields:!1,extraFieldsMessage:"This field was not expected.",missingFieldsMessage:"This field is missing."},f=function(t,e){if(s.apply(this,arguments),this.setExtra(e),!i(t)||t instanceof s)throw new Error("Collection accept only plain object as a first argument");if(t=i(t)&&0===r(Object.keys(t),Object.keys(h)).length?Object.assign({},h,{fields:t}):Object.assign({},h,t),0===Object.keys(t.fields).length)throw new Error('Describe at least one field in "fields" parameter');t.fields=Object.keys(t.fields).reduce((function(e,o){return t.fields[o]instanceof n?e[o]=t.fields[o]:e[o]=new a(t.fields[o]),e}),{}),this.setOptions(t)};(f.prototype=Object.create(s.prototype)).constructor=f,f.prototype.MISSING_FIELD_ERROR="MISSING_FIELD_ERROR",f.prototype.NO_SUCH_FIELD_ERROR="NO_SUCH_FIELD_ERROR",f.prototype.validate=function(t,e,o,r){var s=this.getOptions();return(i(t)||c(t))&&(Object.keys(s.fields).forEach((function(r){void 0===t[r]&&(s.fields[r]instanceof l||s.allowMissingFields||e.buildViolation(s.missingFieldsMessage).atPath(void 0===o?r:o+"."+r).setParameter("{{ field }}",r).setCode(f.prototype.MISSING_FIELD_ERROR).setInvalidValue(t).addViolation())})),s.allowExtraFields||u(t,(function(r,i){void 0===s.fields[i]&&e.buildViolation(s.extraFieldsMessage).atPath(void 0===o?i:o+"."+i).setParameter("{{ field }}",i).setCode(f.prototype.NO_SUCH_FIELD_ERROR).setInvalidValue(t).addViolation()}))),Promise.resolve("resolve Collection2")},f.prototype.validateChildren=function(t,e,o,r){var i,s=this.getOptions();u(t,(function(r,n){(i=s.fields[n])&&p({value:t[n],constraints:i.getOptions(),context:e,path:o?o+"."+n:n})}))},t.exports=f},311:(t,e,o)=>{"use strict";function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}var i=o(759),s=o(228),n=o(588),a={minMessage:"This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more.",maxMessage:"This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less.",exactMessage:"This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements."};function l(){var t=Array.prototype.slice.call(arguments);if(n.apply(this,t),0===t.length)throw new Error("Count: options must be given for this constraint");var e=t[0];if(this.setExtra(t[1]),Number.isInteger(e)&&(e={min:e,max:e}),!s(e))throw new Error("Count: Wrong parameter type have been given to this constraint, typeof: "+r(e));if(void 0===(e=Object.assign({},a,e)).min&&void 0===e.max)throw new Error('Count: Either option "min" or "max" must be given for constraint');if(void 0!==e.min&&!Number.isInteger(e.min))throw new Error("Count: min should be integer");if(void 0!==e.max&&!Number.isInteger(e.max))throw new Error("Count: max should be integer");if(e.min<0)throw new Error("Count: min should be greater than 0");if(e.max<0)throw new Error("Count: max should be greater than 0");this.setOptions(e)}l.prototype=Object.create(n.prototype),l.prototype.constructor=l,l.prototype.TOO_FEW_ERROR="TOO_FEW_ERROR",l.prototype.TOO_MANY_ERROR="TOO_MANY_ERROR",l.prototype.validate=function(t,e,o,r){var n=this.getOptions(),a=!1;if(i(t)&&(a=t.length),!1===a&&s(t)&&(a=Object.keys(t).length),!1!==a){if(void 0!==n.max&&a>n.max)return e.buildViolation(n.min===n.max?n.exactMessage:n.maxMessage).atPath(o).setParameter("{{ count }}",a).setParameter("{{ limit }}",n.max).setInvalidValue(t).setPlural(1===n.max?0:1).setCode(l.prototype.TOO_MANY_ERROR).addViolation(),r&&r.stop?Promise.reject("stop Count"):Promise.resolve("resolve Count");if(void 0!==n.min&&a{"use strict";var r=o(588),i={message:"This value is not a valid email address."},s=function(t,e){r.apply(this,arguments),this.setExtra(e),"string"==typeof t&&(t={message:t}),this.setOptions(Object.assign({},i,t))};(s.prototype=Object.create(r.prototype)).constructor=s,s.prototype.INVALID_EMAIL_ERROR="INVALID_EMAIL_ERROR",s.prototype.validate=function(t,e,o,r){var i=this.getOptions();return!s.prototype.logic(t)&&(e.buildViolation(i.message).atPath(o).setCode(s.prototype.INVALID_EMAIL_ERROR).setInvalidValue(t).addViolation(),r&&r.stop)?Promise.reject("stop Email"):Promise.resolve("resolve Email")},s.prototype.logic=function(t){return"string"==typeof t&&/^.+\@\S+\.\S+$/.test(t)},t.exports=s},165:(t,e,o)=>{"use strict";var r=o(588),i={message:"This value should be false."},s=function(t,e){r.apply(this,arguments),this.setExtra(e),"string"==typeof t&&(t={message:t}),this.setOptions(Object.assign({},i,t))};(s.prototype=Object.create(r.prototype)).constructor=s,s.prototype.NOT_FALSE_ERROR="NOT_FALSE_ERROR",s.prototype.validate=function(t,e,o,r){var i=this.getOptions();return!1!==t&&(e.buildViolation(i.message).atPath(o).setCode(s.prototype.NOT_FALSE_ERROR).setInvalidValue(t).addViolation(),r&&r.stop)?Promise.reject("stop IsFalse"):Promise.resolve("resolve IsFalse")},t.exports=s},682:(t,e,o)=>{"use strict";var r=o(588),i={message:"This value should be null."},s=function(t,e){r.apply(this,arguments),this.setExtra(e),"string"==typeof t&&(t={message:t}),this.setOptions(Object.assign({},i,t))};(s.prototype=Object.create(r.prototype)).constructor=s,s.prototype.NOT_NULL_ERROR="NOT_NULL_ERROR",s.prototype.validate=function(t,e,o,r){var i=this.getOptions();return null!==t&&(e.buildViolation(i.message).atPath(o).setCode(s.prototype.NOT_NULL_ERROR).setInvalidValue(t).addViolation(),r&&r.stop)?Promise.reject("stop IsNull"):Promise.resolve("resolve IsNull")},t.exports=s},786:(t,e,o)=>{"use strict";var r=o(588),i={message:"This value should be true."},s=function(t,e){r.apply(this,arguments),this.setExtra(e),"string"==typeof t&&(t={message:t}),this.setOptions(Object.assign({},i,t))};(s.prototype=Object.create(r.prototype)).constructor=s,s.prototype.NOT_TRUE_ERROR="NOT_TRUE_ERROR",s.prototype.validate=function(t,e,o,r){var i=this.getOptions();return!0!==t&&(e.buildViolation(i.message).atPath(o).setCode(s.prototype.NOT_TRUE_ERROR).setInvalidValue(t).addViolation(),r&&r.stop)?Promise.reject("stop IsTrue"):Promise.resolve("resolve IsTrue")},t.exports=s},736:(t,e,o)=>{"use strict";function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}var i=o(228),s=o(588),n={maxMessage:"This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less.",minMessage:"This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.",exactMessage:"This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters."};function a(){var t=Array.prototype.slice.call(arguments);if(s.apply(this,t),0===t.length)throw new Error("Length: options must be given for this constraint");var e=t[0];if(this.setExtra(t[1]),Number.isInteger(e)&&(e={min:e,max:e}),!i(e))throw new Error("Length: Wrong parameter type have been given to this constraint, typeof: "+r(e));if(void 0===(e=Object.assign({},n,e)).min&&void 0===e.max)throw new Error('Length: Either option "min" or "max" must be given for constraint');this.setOptions(e)}a.prototype=Object.create(s.prototype),a.prototype.constructor=a,a.prototype.TOO_SHORT_ERROR="TOO_SHORT_ERROR",a.prototype.TOO_LONG_ERROR="TOO_LONG_ERROR",a.prototype.validate=function(t,e,o,r){var i=this.getOptions();if("string"==typeof t){var s=t.length;if(void 0!==i.max&&s>i.max)return e.buildViolation(i.min===i.max?i.exactMessage:i.maxMessage).atPath(o).setPlural(1===i.max?0:1).setParameter("{{ value }}",t).setParameter("{{ limit }}",i.max).setInvalidValue(t).setCode(a.prototype.TOO_LONG_ERROR).setExtra(r).addViolation(),r&&r.stop?Promise.reject("stop Length"):Promise.resolve("resolve Length");if(void 0!==i.min&&s{"use strict";var r=o(588),i=o(614),s={message:"This value should not be blank."},n=function(t,e){r.apply(this,arguments),this.setExtra(e),"string"==typeof t&&(t={message:t}),this.setOptions(Object.assign({},s,t))};(n.prototype=Object.create(r.prototype)).constructor=n,n.prototype.IS_BLANK_ERROR="IS_BLANK_ERROR",n.prototype.validate=function(t,e,o,r){var s=this.getOptions();return i.prototype.logic(t)&&(e.buildViolation(s.message).atPath(o).setCode(n.prototype.IS_BLANK_ERROR).setInvalidValue(t).addViolation(),r&&r.stop)?Promise.reject("stop NotBlank"):Promise.resolve("resolve NotBlank")},t.exports=n},857:(t,e,o)=>{"use strict";var r=o(588),i={message:"This value should be true."},s=function(t,e){r.apply(this,arguments),this.setExtra(e),"string"==typeof t&&(t={message:t}),this.setOptions(Object.assign({},i,t))};(s.prototype=Object.create(r.prototype)).constructor=s,s.prototype.IS_NULL_ERROR="IS_NULL_ERROR",s.prototype.validate=function(t,e,o,r){var i=this.getOptions();return null===t&&(e.buildViolation(i.message).atPath(o).setCode(s.prototype.IS_NULL_ERROR).setInvalidValue(t).addViolation(),r&&r.stop)?Promise.reject("stop NotNull"):Promise.resolve("resolve NotNull")},t.exports=s},288:(t,e,o)=>{"use strict";var r=o(475),i=o(588),s=o(228),n=function(t,e){if(i.apply(this,arguments),s(e)){if(e instanceof r)throw new Error("Optional: extra can't be instance of Existence");if(e instanceof i)throw new Error("Optional: extra can't be instance of Constraint")}this.setExtra(e),this.setOptions(t)};(n.prototype=Object.create(r.prototype)).constructor=n,t.exports=n},146:(t,e,o)=>{"use strict";var r=o(588),i=o(228),s={message:"This value is not valid.",match:!0},n=function t(e,o){if(r.apply(this,arguments),this.setExtra(o),t.prototype.isRegex(e)&&(e={pattern:e}),!i(e))throw new Error("Regex: first argument must be regex or object");if(!t.prototype.isRegex(e.pattern))throw new Error("Regex: 'pattern' is not specified");this.setOptions(Object.assign({},s,e))};(n.prototype=Object.create(r.prototype)).constructor=n,n.prototype.REGEX_FAILED_ERROR="REGEX_FAILED_ERROR",n.prototype.validate=function(t,e,o,r){var i=this.getOptions();return!n.prototype.logic(t,i.pattern,i.match)&&(e.buildViolation(i.message).atPath(o).setCode(n.prototype.REGEX_FAILED_ERROR).setInvalidValue(t).addViolation(),r&&r.stop)?Promise.reject("stop Regex"):Promise.resolve("resolve Regex")},n.prototype.isRegex=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},n.prototype.logic=function(t,e,o){t+="";var r=e.test(t);return o?r:!r},t.exports=n},161:(t,e,o)=>{"use strict";var r=o(475),i=o(588),s=o(228),n=function(t,e){if(i.apply(this,arguments),s(e)){if(e instanceof r)throw new Error("Required: extra can't be instance of Existence");if(e instanceof i)throw new Error("Required: extra can't be instance of Constraint")}this.setExtra(e),this.setOptions(t)};(n.prototype=Object.create(r.prototype)).constructor=n,t.exports=n},457:(t,e,o)=>{"use strict";function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}var i=o(228),s=o(759),n=o(588),a={message:"This value should be of type '{{ type }}'."},l=function t(e,o){n.apply(this,arguments),this.setExtra(o),s(e)&&(e={type:e}),"string"==typeof e&&(e={type:e}),e=Object.assign({},a,e),s(e.type)||(e.type=[e.type]);for(var r=0,i=e.type.length;r{"use strict";function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,r=new Array(e);o1&&(d=(e=d).then.apply(e,function(t){if(Array.isArray(t))return r(t)}(o=n.then(2500))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||function(t,e){if(t){if("string"==typeof t)return r(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?r(t,e):void 0}}(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())),u>0&&(d=d.then((function(t){return console.log("debug resolved:",JSON.stringify(t)),t}),(function(t){return console.log("debug rejected:",JSON.stringify(t)),Promise.reject(t)})))}(y.shift());var m=function(){return f.getViolations()};return d.then(m,(function(t){try{if(h===p.justStop)return m();if(h===p.raw)return Promise.reject(t);var e=t.filter((function(t){return!1===t.resolved})).map((function(t){return t.data instanceof Error?t.data:new Error(String(t.data))})),o=e.find((function(t){return t instanceof l}));if(h===p.exceptionalThrow&&o)return Promise.reject(o);if(h===p.errors)return Promise.reject(e);var r=e.shift();return h===p.firstError&&r?Promise.reject(r):m()}catch(t){return Promise.reject(t)}}))};u.Required=o(161),u.Optional=o(288),u.Collection=o(663),u.All=o(569),u.Blank=o(614),u.Callback=o(787),u.Choice=o(796),u.Count=o(311),u.Email=o(454),u.IsFalse=o(165),u.IsNull=o(682),u.IsTrue=o(786),u.Length=o(736),u.NotBlank=o(234),u.NotNull=o(857),u.Regex=o(146),u.Type=o(457),u.ValidatorLogicError=l,t.exports=u},533:(t,e,o)=>{"use strict";var r=o(578),i=o(759);function s(t,e,o){return o.indexOf(t)===e}function n(t){this.violations=t}n.prototype.getRaw=function(){return this.violations.map((function(t){return t.length>4&&t.pop(),t}))},n.prototype.getFlat=function(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],o=this.violations.reduce((function(e,o){return e[t=o[0]||""]||(e[t]=[]),e[t].push(o),e}),{});return Object.keys(o).reduce((function(t,r){return t[r]=o[r],t[r].sort((function(t,e){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return"number"==typeof t[4]?o=t[4]:t[4]&&void 0!==t[4].order&&(o=t[4].order),"number"==typeof e[4]?r=e[4]:e[4]&&void 0!==e[4].order&&(r=e[4].order),r-o})),t[r]=t[r].map((function(t){return t[1]})),e||(t[r]=t[r].shift()),t}),{})},n.prototype.getTree=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.getFlat(t);return Object.keys(e).reduce((function(t,o){return r(t,o,e[o])}),{})},n.prototype.findByCodes=function(t){var e=this;i(t)||(t=[t]),t=t.filter(s);for(var o=[],r=function(r,i){o=o.concat(e.violations.filter((function(e){return e[2]===t[r]})))},n=0,a=t.length;n{"use strict";var r=o(803),i=o(533),s=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.violations=[],this.rootData=t,this.extra=e,this.stack={}};s.prototype.buildViolation=function(){var t=Array.prototype.slice.call(arguments);if(0===t.length)throw new Error("new Context(message).buildViolation(message): message not specified");if("string"!=typeof t[0])throw new Error("new Context(message).buildViolation(message): message arg must be string");return new r(t[0],this)},s.prototype.addViolation=function(t,e,o,r,i){var s=[t,e,o,r];void 0!==i&&s.push(i),this.violations.push(s)},s.prototype.addTrigger=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0;return this.stack[t]?this.stack[t].push(e):this.stack[t]=[e],this},s.prototype.getTriggers=function(){var t=this,e=Object.keys(this.stack).sort().reduce((function(e,o){return t.stack[o].length&&e.push(t.stack[o]),e}),[]);return this.stack={},e},s.prototype.getViolations=function(){return new i(this.violations)},s.prototype.getRoot=function(){return this.rootData},s.prototype.getExtra=function(){return this.extra},t.exports=s},803:t=>{"use strict";var e=function(t,e){this.parameters={},this.code=void 0,this.path=void 0,this.plural=!1,this.invalidValue=void 0,this.extra=void 0,this.message=t,this.context=e};e.prototype.setParameter=function(t,e){return this.parameters[t]=e,this},e.prototype.setCode=function(t){return this.code=t,this},e.prototype.atPath=function(t){return this.path=t,this},e.prototype.setPlural=function(t){if(!Number.isInteger(t)||t<0)throw new Error("ViolationBuilder.setPlural(plural) - plural parameter should be integer in range 0-inifinty");return this.plural=t,this},e.prototype.setInvalidValue=function(t){return this.invalidValue=t,this},e.prototype.setExtra=function(t){return this.extra=t,this},e.prototype.addViolation=function(){var t=this;if(void 0===this.code)throw new Error("ViolationBuilder: this.code === undefined, call ViolationBuilder->setCode(code)");var e=this.message;if("string"==typeof e&&e.indexOf("|")>-1&&!1!==this.plural&&this.plural>-1){var o=e.split("|");o.length>this.plural&&(e=o[this.plural])}return Object.keys(this.parameters).map((function(o){var r;do{r=e,e=e.replace(o,t.parameters[o])}while(r!==e)})),this.context.addViolation(this.path,e,this.code,this.invalidValue,this.extra),this},t.exports=e},764:(t,e,o)=>{"use strict";var r=o(475),i=o(588),s=o(569),n=o(759),a=o(573);t.exports=function t(e){var o=e.value,l=e.constraints,p=e.context,c=e.path,u=e.final,h=void 0!==u&&u;if(l instanceof r)return t({value:o,constraints:l.getOptions(),context:p,path:c,final:h});if(l instanceof i&&(l=[l]),!n(l))return h?p.getTriggers():void 0;for(var f=function(e,i){if(l[e]instanceof r)t({value:o,constraints:l[e].getOptions(),context:p,path:c});else if(l[e]instanceof s){var n=c?function(t){return c+"."+t}:function(t){return t},u=l[e].getOptions();a(o,(function(e,o){t({value:e,constraints:u,context:p,path:n(o)})}))}else h=l[e].getExtra(),p.addTrigger(h?h.async:0,(function(){return l[e].validate(o,p,c,h)})),l[e].validateChildren&&function(t){l[e].validateChildren(o,p,c,t)}(l[e].getExtra());var h},y=0,d=l.length;y{"use strict";function r(){if(!(this instanceof r))throw new Error("It is necessary to use operator 'new' with all constraints")}o(228);var i="_ERROR",s=i.length;r.prototype.errorNames=function(){var t=this;return r.prototype._errorNames||(r.prototype._errorNames=Object.keys(this.constructor.prototype).reduce((function(e,o){return"string"==typeof t.constructor.prototype[o]&&o===o.toUpperCase()&&o.substring(o.length-s)===i&&(e[o]=o),e}),{})),r.prototype._errorNames},r.prototype.getOptions=function(){return this.opt},r.prototype.setOptions=function(t){return this.opt=t,this},r.prototype.setExtra=function(t){return this.extra=t,this},r.prototype.getExtra=function(){return this.extra},r.prototype.validate=!1,r.prototype.validateChildren=!1,t.exports=r},475:(t,e,o)=>{"use strict";var r=o(588),i=function(){r.apply(this,arguments)};(i.prototype=Object.create(r.prototype)).constructor=i,t.exports=i},538:(t,e,o)=>{"use strict";var r=o(759);t.exports=function(t,e){return r(t)&&r(e)?t.reduce((function(t,o){return e.indexOf(o)>-1&&t.push(o),t}),[]):[]}},351:t=>{"use strict";var e=function(t,e){return new Promise((function(o){return t?setTimeout(o,t,e):o(e)}))};e.reject=function(t,e){return new Promise((function(o,r){return t?setTimeout(r,t,e):r(e)}))},e.then=function(t){return[function(o){return e(t,o)},function(o){return e.reject(t,o)}]},t.exports=e},573:(t,e,o)=>{"use strict";var r=o(759),i=o(228);t.exports=function(t,e,o){if(r(t)){for(var s=0,n=t.length;s{"use strict";t.exports=function(t){return"[object Array]"===Object.prototype.toString.call(t)}},228:t=>{"use strict";t.exports=function(t){return"[object Object]"===Object.prototype.toString.call(t)}},578:(t,e,o)=>{"use strict";var r=o(759),i=o(228);t.exports=function(t,e,o){if("string"==typeof e&&(e=e.split(".")),"number"==typeof e&&(e+=""),i(e)&&(e=Object.values(e).map((function(t){return t+""}))),"string"==typeof e||e||"0"===e||""===e||(e=[]),r(e)||(e=[e]),e.length){var s,n=!0,a=r(t);a||i(t)||(t={});for(var l,p,c=t,u=t;e.length;){if(s=e.shift(),n&&(n=!1,a&&!/^\d+$/.test(s)&&""!==s))throw new Error("if source is array and key is not integer nor empty string then its not possible to add to array, given key: "+JSON.stringify(s));if(c=u,!e.length)return r(c)&&""===s?c.push(o):c[s]=o,t;l=i(c[s]),p=r(c[s]),l||p||(""===e[0]?p||(c[s]=[]):l||(c[s]={})),u=c[s]}}return o}}},e={},function o(r){var i=e[r];if(void 0!==i)return i.exports;var s=e[r]={exports:{}};return t[r](s,s.exports,o),s.exports}(331);var t,e})); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.spvalidation=e():t.spvalidation=e()}(self,(()=>{return t={219:(t,e,o)=>{t.exports=o(559)},559:t=>{function e(t){return new Error("promiseall error: "+t)}t.exports=function(t){if(!Array.isArray(t))throw e("list is not an array");var o=t.length;if(0===o)return Promise.resolve([]);for(var r,i=!1,s=0,n=t.length;s{function e(){var t=Error.apply(this,arguments);t.name=this.name="ValidatorLogicError",this.stack=t.stack,this.message=t.message}e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,t.exports=e},569:(t,e,o)=>{"use strict";var r=o(588),i=function(t,e){r.apply(this,arguments),this.setExtra(e),this.setOptions(t)};(i.prototype=Object.create(r.prototype)).constructor=i,t.exports=i},614:(t,e,o)=>{"use strict";var r=o(228),i=o(759),s=o(588),n={message:"This value should be blank."},a=function(t,e){s.apply(this,arguments),this.setExtra(e),"string"==typeof t&&(t={message:t}),this.setOptions(Object.assign({},n,t))};(a.prototype=Object.create(s.prototype)).constructor=a,a.prototype.NOT_BLANK_ERROR="NOT_BLANK_ERROR",a.prototype.validate=function(t,e,o,r){var i=this.getOptions();return!a.prototype.logic(t)&&(e.buildViolation(i.message).atPath(o).setCode(a.prototype.NOT_BLANK_ERROR).setInvalidValue(t).addViolation(),r&&r.stop)?Promise.reject("stop Blank"):Promise.resolve("resolve Blank")},a.prototype.logic=function(t){var e=!1;switch(!0){case!t:case"0"===t:case i(t)&&0===t.length:case r(t)&&0===Object.keys(t).length:e=!0}return e},t.exports=a},787:(t,e,o)=>{"use strict";var r=o(588),i=function(t,e){if(r.apply(this,arguments),this.setExtra(e),"function"!=typeof t)throw new Error("Callback constraint first arg should be function");this.setOptions(t)};(i.prototype=Object.create(r.prototype)).constructor=i,i.prototype.validate=function(t,e,o,r){var i=this.getOptions();return Promise.resolve(i(t,e,o,r))},t.exports=i},796:(t,e,o)=>{"use strict";o(228);var r=o(759),i=o(588),s={message:"The value you selected is not a valid choice.",multipleMessage:"One or more of the given values is invalid.",minMessage:"You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices.",maxMessage:"You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices.",multiple:!1},n=function(t,e){if(i.apply(this,arguments),this.setExtra(e),r(t)&&(t={choices:t}),t=Object.assign({},s,t),!r(t.choices)||0===t.choices.length)throw new Error("Choice: choices have to be non empty list");this.setOptions(t)};(n.prototype=Object.create(i.prototype)).constructor=n,n.prototype.NO_SUCH_CHOICE_ERROR="NO_SUCH_CHOICE_ERROR",n.prototype.TOO_FEW_ERROR="TOO_FEW_ERROR",n.prototype.TOO_MANY_ERROR="TOO_MANY_ERROR";var a=function(t,e){return t&&t.stop?Promise.reject("stop Choice"+e):Promise.resolve("resolve Choice"+e)};n.prototype.validate=function(t,e,o,i){var s=this.getOptions();if(null===t)return Promise.resolve("Choice");if(s.multiple){if(r(t)){for(var l=t.length,p=0,c=l;ps.max)return e.buildViolation(s.maxMessage).atPath(o).setParameter("{{ limit }}",s.max).setPlural(1===s.max?0:1).setInvalidValue(t).setCode(n.prototype.TOO_MANY_ERROR).setExtra(i).addViolation(),a(i,3)}}else if(-1===s.choices.indexOf(t))return e.buildViolation(s.message).atPath(o).setParameter("{{ value }}",t).setInvalidValue(t).setCode(n.prototype.NO_SUCH_CHOICE_ERROR).setExtra(i).addViolation(),a(i,4);return Promise.resolve("Choice1")},t.exports=n},663:(t,e,o)=>{"use strict";var r=o(538),i=o(228),s=o(588),n=o(475),a=o(161),l=o(288),p=o(764),c=o(759),u=o(573),h={fields:{},allowExtraFields:!1,allowMissingFields:!1,extraFieldsMessage:"This field was not expected.",missingFieldsMessage:"This field is missing."},f=function(t,e){if(s.apply(this,arguments),this.setExtra(e),!i(t)||t instanceof s)throw new Error("Collection accept only plain object as a first argument");if(t=i(t)&&0===r(Object.keys(t),Object.keys(h)).length?Object.assign({},h,{fields:t}):Object.assign({},h,t),0===Object.keys(t.fields).length)throw new Error('Describe at least one field in "fields" parameter');t.fields=Object.keys(t.fields).reduce((function(e,o){return t.fields[o]instanceof n?e[o]=t.fields[o]:e[o]=new a(t.fields[o]),e}),{}),this.setOptions(t)};(f.prototype=Object.create(s.prototype)).constructor=f,f.prototype.MISSING_FIELD_ERROR="MISSING_FIELD_ERROR",f.prototype.NO_SUCH_FIELD_ERROR="NO_SUCH_FIELD_ERROR",f.prototype.validate=function(t,e,o,r){var s=this.getOptions();return(i(t)||c(t))&&(Object.keys(s.fields).forEach((function(r){void 0===t[r]&&(s.fields[r]instanceof l||s.allowMissingFields||e.buildViolation(s.missingFieldsMessage).atPath(void 0===o?r:o+"."+r).setParameter("{{ field }}",r).setCode(f.prototype.MISSING_FIELD_ERROR).setInvalidValue(t).addViolation())})),s.allowExtraFields||u(t,(function(r,i){void 0===s.fields[i]&&e.buildViolation(s.extraFieldsMessage).atPath(void 0===o?i:o+"."+i).setParameter("{{ field }}",i).setCode(f.prototype.NO_SUCH_FIELD_ERROR).setInvalidValue(t).addViolation()}))),Promise.resolve("resolve Collection2")},f.prototype.validateChildren=function(t,e,o,r){var i,s=this.getOptions();u(t,(function(r,n){(i=s.fields[n])&&p({value:t[n],constraints:i.getOptions(),context:e,path:o?o+"."+n:n})}))},t.exports=f},311:(t,e,o)=>{"use strict";function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}var i=o(759),s=o(228),n=o(588),a={minMessage:"This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more.",maxMessage:"This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less.",exactMessage:"This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements."};function l(){var t=Array.prototype.slice.call(arguments);if(n.apply(this,t),0===t.length)throw new Error("Count: options must be given for this constraint");var e=t[0];if(this.setExtra(t[1]),Number.isInteger(e)&&(e={min:e,max:e}),!s(e))throw new Error("Count: Wrong parameter type have been given to this constraint, typeof: "+r(e));if(void 0===(e=Object.assign({},a,e)).min&&void 0===e.max)throw new Error('Count: Either option "min" or "max" must be given for constraint');if(void 0!==e.min&&!Number.isInteger(e.min))throw new Error("Count: min should be integer");if(void 0!==e.max&&!Number.isInteger(e.max))throw new Error("Count: max should be integer");if(e.min<0)throw new Error("Count: min should be greater than 0");if(e.max<0)throw new Error("Count: max should be greater than 0");this.setOptions(e)}l.prototype=Object.create(n.prototype),l.prototype.constructor=l,l.prototype.TOO_FEW_ERROR="TOO_FEW_ERROR",l.prototype.TOO_MANY_ERROR="TOO_MANY_ERROR",l.prototype.validate=function(t,e,o,r){var n=this.getOptions(),a=!1;if(i(t)&&(a=t.length),!1===a&&s(t)&&(a=Object.keys(t).length),!1!==a){if(void 0!==n.max&&a>n.max)return e.buildViolation(n.min===n.max?n.exactMessage:n.maxMessage).atPath(o).setParameter("{{ count }}",a).setParameter("{{ limit }}",n.max).setInvalidValue(t).setPlural(1===n.max?0:1).setCode(l.prototype.TOO_MANY_ERROR).addViolation(),r&&r.stop?Promise.reject("stop Count"):Promise.resolve("resolve Count");if(void 0!==n.min&&a{"use strict";var r=o(588),i={message:"This value is not a valid email address."},s=function(t,e){r.apply(this,arguments),this.setExtra(e),"string"==typeof t&&(t={message:t}),this.setOptions(Object.assign({},i,t))};(s.prototype=Object.create(r.prototype)).constructor=s,s.prototype.INVALID_EMAIL_ERROR="INVALID_EMAIL_ERROR",s.prototype.validate=function(t,e,o,r){var i=this.getOptions();return!s.prototype.logic(t)&&(e.buildViolation(i.message).atPath(o).setCode(s.prototype.INVALID_EMAIL_ERROR).setInvalidValue(t).addViolation(),r&&r.stop)?Promise.reject("stop Email"):Promise.resolve("resolve Email")},s.prototype.logic=function(t){return"string"==typeof t&&/^.+\@\S+\.\S+$/.test(t)},t.exports=s},165:(t,e,o)=>{"use strict";var r=o(588),i={message:"This value should be false."},s=function(t,e){r.apply(this,arguments),this.setExtra(e),"string"==typeof t&&(t={message:t}),this.setOptions(Object.assign({},i,t))};(s.prototype=Object.create(r.prototype)).constructor=s,s.prototype.NOT_FALSE_ERROR="NOT_FALSE_ERROR",s.prototype.validate=function(t,e,o,r){var i=this.getOptions();return!1!==t&&(e.buildViolation(i.message).atPath(o).setCode(s.prototype.NOT_FALSE_ERROR).setInvalidValue(t).addViolation(),r&&r.stop)?Promise.reject("stop IsFalse"):Promise.resolve("resolve IsFalse")},t.exports=s},682:(t,e,o)=>{"use strict";var r=o(588),i={message:"This value should be null."},s=function(t,e){r.apply(this,arguments),this.setExtra(e),"string"==typeof t&&(t={message:t}),this.setOptions(Object.assign({},i,t))};(s.prototype=Object.create(r.prototype)).constructor=s,s.prototype.NOT_NULL_ERROR="NOT_NULL_ERROR",s.prototype.validate=function(t,e,o,r){var i=this.getOptions();return null!==t&&(e.buildViolation(i.message).atPath(o).setCode(s.prototype.NOT_NULL_ERROR).setInvalidValue(t).addViolation(),r&&r.stop)?Promise.reject("stop IsNull"):Promise.resolve("resolve IsNull")},t.exports=s},786:(t,e,o)=>{"use strict";var r=o(588),i={message:"This value should be true."},s=function(t,e){r.apply(this,arguments),this.setExtra(e),"string"==typeof t&&(t={message:t}),this.setOptions(Object.assign({},i,t))};(s.prototype=Object.create(r.prototype)).constructor=s,s.prototype.NOT_TRUE_ERROR="NOT_TRUE_ERROR",s.prototype.validate=function(t,e,o,r){var i=this.getOptions();return!0!==t&&(e.buildViolation(i.message).atPath(o).setCode(s.prototype.NOT_TRUE_ERROR).setInvalidValue(t).addViolation(),r&&r.stop)?Promise.reject("stop IsTrue"):Promise.resolve("resolve IsTrue")},t.exports=s},736:(t,e,o)=>{"use strict";function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}var i=o(228),s=o(588),n={maxMessage:"This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less.",minMessage:"This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.",exactMessage:"This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters."};function a(){var t=Array.prototype.slice.call(arguments);if(s.apply(this,t),0===t.length)throw new Error("Length: options must be given for this constraint");var e=t[0];if(this.setExtra(t[1]),Number.isInteger(e)&&(e={min:e,max:e}),!i(e))throw new Error("Length: Wrong parameter type have been given to this constraint, typeof: "+r(e));if(void 0===(e=Object.assign({},n,e)).min&&void 0===e.max)throw new Error('Length: Either option "min" or "max" must be given for constraint');this.setOptions(e)}a.prototype=Object.create(s.prototype),a.prototype.constructor=a,a.prototype.TOO_SHORT_ERROR="TOO_SHORT_ERROR",a.prototype.TOO_LONG_ERROR="TOO_LONG_ERROR",a.prototype.validate=function(t,e,o,r){var i=this.getOptions();if("string"==typeof t){var s=t.length;if(void 0!==i.max&&s>i.max)return e.buildViolation(i.min===i.max?i.exactMessage:i.maxMessage).atPath(o).setPlural(1===i.max?0:1).setParameter("{{ value }}",t).setParameter("{{ limit }}",i.max).setInvalidValue(t).setCode(a.prototype.TOO_LONG_ERROR).setExtra(r).addViolation(),r&&r.stop?Promise.reject("stop Length"):Promise.resolve("resolve Length");if(void 0!==i.min&&s{"use strict";var r=o(588),i=o(614),s={message:"This value should not be blank."},n=function(t,e){r.apply(this,arguments),this.setExtra(e),"string"==typeof t&&(t={message:t}),this.setOptions(Object.assign({},s,t))};(n.prototype=Object.create(r.prototype)).constructor=n,n.prototype.IS_BLANK_ERROR="IS_BLANK_ERROR",n.prototype.validate=function(t,e,o,r){var s=this.getOptions();return i.prototype.logic(t)&&(e.buildViolation(s.message).atPath(o).setCode(n.prototype.IS_BLANK_ERROR).setInvalidValue(t).addViolation(),r&&r.stop)?Promise.reject("stop NotBlank"):Promise.resolve("resolve NotBlank")},t.exports=n},857:(t,e,o)=>{"use strict";var r=o(588),i={message:"This value should be true."},s=function(t,e){r.apply(this,arguments),this.setExtra(e),"string"==typeof t&&(t={message:t}),this.setOptions(Object.assign({},i,t))};(s.prototype=Object.create(r.prototype)).constructor=s,s.prototype.IS_NULL_ERROR="IS_NULL_ERROR",s.prototype.validate=function(t,e,o,r){var i=this.getOptions();return null===t&&(e.buildViolation(i.message).atPath(o).setCode(s.prototype.IS_NULL_ERROR).setInvalidValue(t).addViolation(),r&&r.stop)?Promise.reject("stop NotNull"):Promise.resolve("resolve NotNull")},t.exports=s},288:(t,e,o)=>{"use strict";var r=o(475),i=o(588),s=o(228),n=function(t,e){if(i.apply(this,arguments),s(e)){if(e instanceof r)throw new Error("Optional: extra can't be instance of Existence");if(e instanceof i)throw new Error("Optional: extra can't be instance of Constraint")}this.setExtra(e),this.setOptions(t)};(n.prototype=Object.create(r.prototype)).constructor=n,t.exports=n},146:(t,e,o)=>{"use strict";var r=o(588),i=o(228),s={message:"This value is not valid.",match:!0},n=function t(e,o){if(r.apply(this,arguments),this.setExtra(o),t.prototype.isRegex(e)&&(e={pattern:e}),!i(e))throw new Error("Regex: first argument must be regex or object");if(!t.prototype.isRegex(e.pattern))throw new Error("Regex: 'pattern' is not specified");this.setOptions(Object.assign({},s,e))};(n.prototype=Object.create(r.prototype)).constructor=n,n.prototype.REGEX_FAILED_ERROR="REGEX_FAILED_ERROR",n.prototype.validate=function(t,e,o,r){var i=this.getOptions();return!n.prototype.logic(t,i.pattern,i.match)&&(e.buildViolation(i.message).atPath(o).setCode(n.prototype.REGEX_FAILED_ERROR).setInvalidValue(t).addViolation(),r&&r.stop)?Promise.reject("stop Regex"):Promise.resolve("resolve Regex")},n.prototype.isRegex=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},n.prototype.logic=function(t,e,o){t+="";var r=e.test(t);return o?r:!r},t.exports=n},161:(t,e,o)=>{"use strict";var r=o(475),i=o(588),s=o(228),n=function(t,e){if(i.apply(this,arguments),s(e)){if(e instanceof r)throw new Error("Required: extra can't be instance of Existence");if(e instanceof i)throw new Error("Required: extra can't be instance of Constraint")}this.setExtra(e),this.setOptions(t)};(n.prototype=Object.create(r.prototype)).constructor=n,t.exports=n},457:(t,e,o)=>{"use strict";function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}var i=o(228),s=o(759),n=o(588),a={message:"This value should be of type '{{ type }}'."},l=function t(e,o){n.apply(this,arguments),this.setExtra(o),s(e)&&(e={type:e}),"string"==typeof e&&(e={type:e}),e=Object.assign({},a,e),s(e.type)||(e.type=[e.type]);for(var r=0,i=e.type.length;r{"use strict";function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,r=new Array(e);o1&&(d=(e=d).then.apply(e,function(t){if(Array.isArray(t))return r(t)}(o=n.then(2500))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||function(t,e){if(t){if("string"==typeof t)return r(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?r(t,e):void 0}}(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())),u>0&&(d=d.then((function(t){return console.log("debug resolved:",JSON.stringify(t)),t}),(function(t){return console.log("debug rejected:",JSON.stringify(t)),Promise.reject(t)})))}(y.shift());var m=function(){return f.getViolations()};return d.then(m,(function(t){try{if(h===p.justStop)return m();if(h===p.raw)return Promise.reject(t);var e=t.filter((function(t){return!1===t.resolved})).map((function(t){return t.data instanceof Error?t.data:new Error(String(t.data))})),o=e.find((function(t){return t instanceof l}));if(h===p.exceptionalThrow&&o)return Promise.reject(o);if(h===p.errors)return Promise.reject(e);var r=e.shift();return h===p.firstError&&r?Promise.reject(r):m()}catch(t){return Promise.reject(t)}}))};u.Required=o(161),u.Optional=o(288),u.Collection=o(663),u.All=o(569),u.Blank=o(614),u.Callback=o(787),u.Choice=o(796),u.Count=o(311),u.Email=o(454),u.IsFalse=o(165),u.IsNull=o(682),u.IsTrue=o(786),u.Length=o(736),u.NotBlank=o(234),u.NotNull=o(857),u.Regex=o(146),u.Type=o(457),u.ValidatorLogicError=l,t.exports=u},533:(t,e,o)=>{"use strict";var r=o(578),i=o(759);function s(t,e,o){return o.indexOf(t)===e}function n(t){this.violations=t}n.prototype.getRaw=function(){return this.violations.map((function(t){return t.length>4&&t.pop(),t}))},n.prototype.getFlat=function(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],o=this.violations.reduce((function(e,o){return e[t=o[0]||""]||(e[t]=[]),e[t].push(o),e}),{});return Object.keys(o).reduce((function(t,r){return t[r]=o[r],t[r].sort((function(t,e){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return"number"==typeof t[4]?o=t[4]:t[4]&&void 0!==t[4].order&&(o=t[4].order),"number"==typeof e[4]?r=e[4]:e[4]&&void 0!==e[4].order&&(r=e[4].order),r-o})),t[r]=t[r].map((function(t){return t[1]})),e||(t[r]=t[r].shift()),t}),{})},n.prototype.getTree=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.getFlat(t);return Object.keys(e).reduce((function(t,o){return r(t,o,e[o])}),{})},n.prototype.findByCodes=function(t){var e=this;i(t)||(t=[t]),t=t.filter(s);for(var o=[],r=function(r,i){o=o.concat(e.violations.filter((function(e){return e[2]===t[r]})))},n=0,a=t.length;n{"use strict";var r=o(803),i=o(533),s=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.violations=[],this.rootData=t,this.extra=e,this.stack={}};s.prototype.buildViolation=function(){var t=Array.prototype.slice.call(arguments);if(0===t.length)throw new Error("new Context(message).buildViolation(message): message not specified");if("string"!=typeof t[0])throw new Error("new Context(message).buildViolation(message): message arg must be string");return new r(t[0],this)},s.prototype.addViolation=function(t,e,o,r,i){var s=[t,e,o,r];void 0!==i&&s.push(i),this.violations.push(s)},s.prototype.addTrigger=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0;return this.stack[t]?this.stack[t].push(e):this.stack[t]=[e],this},s.prototype.getTriggers=function(){var t=this,e=Object.keys(this.stack).sort().reduce((function(e,o){return t.stack[o].length&&e.push(t.stack[o]),e}),[]);return this.stack={},e},s.prototype.getViolations=function(){return new i(this.violations)},s.prototype.getRoot=function(){return this.rootData},s.prototype.getExtra=function(){return this.extra},t.exports=s},803:t=>{"use strict";var e=function(t,e){this.parameters={},this.code=void 0,this.path=void 0,this.plural=!1,this.invalidValue=void 0,this.extra=void 0,this.message=t,this.context=e};e.prototype.setParameter=function(t,e){return this.parameters[t]=e,this},e.prototype.setCode=function(t){return this.code=t,this},e.prototype.atPath=function(t){return this.path=t,this},e.prototype.setPlural=function(t){if(!Number.isInteger(t)||t<0)throw new Error("ViolationBuilder.setPlural(plural) - plural parameter should be integer in range 0-inifinty");return this.plural=t,this},e.prototype.setInvalidValue=function(t){return this.invalidValue=t,this},e.prototype.setExtra=function(t){return this.extra=t,this},e.prototype.addViolation=function(){var t=this;if(void 0===this.code)throw new Error("ViolationBuilder: this.code === undefined, call ViolationBuilder->setCode(code)");var e=this.message;if("string"==typeof e&&e.indexOf("|")>-1&&!1!==this.plural&&this.plural>-1){var o=e.split("|");o.length>this.plural&&(e=o[this.plural])}return Object.keys(this.parameters).map((function(o){var r;do{r=e,e=e.replace(o,t.parameters[o])}while(r!==e)})),this.context.addViolation(this.path,e,this.code,this.invalidValue,this.extra),this},t.exports=e},764:(t,e,o)=>{"use strict";var r=o(475),i=o(588),s=o(569),n=o(759),a=o(573);t.exports=function t(e){var o=e.value,l=e.constraints,p=e.context,c=e.path,u=e.final,h=void 0!==u&&u;if(l instanceof r)return t({value:o,constraints:l.getOptions(),context:p,path:c,final:h});if(l instanceof i&&(l=[l]),!n(l))return h?p.getTriggers():void 0;for(var f=function(e,i){if(l[e]instanceof r)t({value:o,constraints:l[e].getOptions(),context:p,path:c});else if(l[e]instanceof s){var n=c?function(t){return c+"."+t}:function(t){return t},u=l[e].getOptions();a(o,(function(e,o){t({value:e,constraints:u,context:p,path:String(n(o))})}))}else h=l[e].getExtra(),p.addTrigger(h?h.async:0,(function(){return l[e].validate(o,p,c,h)})),l[e].validateChildren&&function(t){l[e].validateChildren(o,p,c,t)}(l[e].getExtra());var h},y=0,d=l.length;y{"use strict";function r(){if(!(this instanceof r))throw new Error("It is necessary to use operator 'new' with all constraints")}o(228);var i="_ERROR",s=i.length;r.prototype.errorNames=function(){var t=this;return r.prototype._errorNames||(r.prototype._errorNames=Object.keys(this.constructor.prototype).reduce((function(e,o){return"string"==typeof t.constructor.prototype[o]&&o===o.toUpperCase()&&o.substring(o.length-s)===i&&(e[o]=o),e}),{})),r.prototype._errorNames},r.prototype.getOptions=function(){return this.opt},r.prototype.setOptions=function(t){return this.opt=t,this},r.prototype.setExtra=function(t){return this.extra=t,this},r.prototype.getExtra=function(){return this.extra},r.prototype.validate=!1,r.prototype.validateChildren=!1,t.exports=r},475:(t,e,o)=>{"use strict";var r=o(588),i=function(){r.apply(this,arguments)};(i.prototype=Object.create(r.prototype)).constructor=i,t.exports=i},538:(t,e,o)=>{"use strict";var r=o(759);t.exports=function(t,e){return r(t)&&r(e)?t.reduce((function(t,o){return e.indexOf(o)>-1&&t.push(o),t}),[]):[]}},351:t=>{"use strict";var e=function(t,e){return new Promise((function(o){return t?setTimeout(o,t,e):o(e)}))};e.reject=function(t,e){return new Promise((function(o,r){return t?setTimeout(r,t,e):r(e)}))},e.then=function(t){return[function(o){return e(t,o)},function(o){return e.reject(t,o)}]},t.exports=e},573:(t,e,o)=>{"use strict";var r=o(759),i=o(228);t.exports=function(t,e,o){if(r(t)){for(var s=0,n=t.length;s{"use strict";t.exports=function(t){return"[object Array]"===Object.prototype.toString.call(t)}},228:t=>{"use strict";t.exports=function(t){return"[object Object]"===Object.prototype.toString.call(t)}},578:(t,e,o)=>{"use strict";var r=o(759),i=o(228);t.exports=function(t,e,o){if("string"==typeof e&&(e=e.split(".")),"number"==typeof e&&(e+=""),i(e)&&(e=Object.values(e).map((function(t){return t+""}))),"string"==typeof e||e||"0"===e||""===e||(e=[]),r(e)||(e=[e]),e.length){var s,n=!0,a=r(t);a||i(t)||(t={});for(var l,p,c=t,u=t;e.length;){if(s=e.shift(),n&&(n=!1,a&&!/^\d+$/.test(s)&&""!==s))throw new Error("if source is array and key is not integer nor empty string then its not possible to add to array, given key: "+JSON.stringify(s));if(c=u,!e.length)return r(c)&&""===s?c.push(o):c[s]=o,t;l=i(c[s]),p=r(c[s]),l||p||(""===e[0]?p||(c[s]=[]):l||(c[s]={})),u=c[s]}}return o}}},e={},function o(r){var i=e[r];if(void 0!==i)return i.exports;var s=e[r]={exports:{}};return t[r](s,s.exports,o),s.exports}(331);var t,e})); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ee63d0f..e034c38 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { "name": "@stopsopa/validator", - "version": "0.0.115", + "version": "0.0.116", "lockfileVersion": 1 } diff --git a/package.json b/package.json index 23a2b56..ad987e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@stopsopa/validator", - "version": "0.0.115", + "version": "0.0.116", "description": "", "main": "validator", "scripts": {