Socket
Socket
Sign inDemoInstall

@kingshott/iodine

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kingshott/iodine - npm Package Compare versions

Comparing version 8.2.0 to 8.2.1

2

dist/iodine.min.esm.js

@@ -1,2 +0,2 @@

class e{constructor(){this.locale=void 0,this.messages={after:"The date must be after: '[PARAM]'",afterOrEqual:"The date must be after or equal to: '[PARAM]'",array:"[FIELD] must be an array",before:"The date must be before: '[PARAM]'",beforeOrEqual:"The date must be before or equal to: '[PARAM]'",boolean:"[FIELD] must be true or false",date:"[FIELD] must be a date",different:"[FIELD] must be different to '[PARAM]'",endsWith:"[FIELD] must end with '[PARAM]'",email:"[FIELD] must be a valid email address",falsy:"[FIELD] must be a falsy value (false, 'false', 0 or '0')",in:"[FIELD] must be one of the following options: [PARAM]",integer:"[FIELD] must be an integer",json:"[FIELD] must be a parsable JSON object string",max:"[FIELD] must be less than or equal to [PARAM]",min:"[FIELD] must be greater than or equal to [PARAM]",maxLength:"[FIELD] must not be greater than '[PARAM]' in character length",minLength:"[FIELD] must not be less than '[PARAM]' character length",notIn:"[FIELD] must not be one of the following options: [PARAM]",numeric:"[FIELD] must be numeric",optional:"[FIELD] is optional",regexMatch:"[FIELD] must satisify the regular expression: [PARAM]",required:"[FIELD] must be present",same:"[FIELD] must be '[PARAM]'",startsWith:"[FIELD] must start with '[PARAM]'",string:"[FIELD] must be a string",truthy:"[FIELD] must be a truthy value (true, 'true', 1 or '1')",url:"[FIELD] must be a valid url",uuid:"[FIELD] must be a valid UUID"}}_compare(e,t,r,s=!1){return!!this.assertDate(e)&&!(!this.assertDate(t)&&!this.assertInteger(t))&&(t="number"==typeof t?t:t.getTime(),"less"===r&&s?e.getTime()<=t:"less"!==r||s?"more"===r&&s?e.getTime()>=t:"more"!==r||s?void 0:e.getTime()>t:e.getTime()<t)}_error(e,t){let{param:r,field:s}="object"==typeof t?t:{param:t,field:void 0};const a=e.split(":");let i=a.shift();r=r||a.join(":"),["after","afterOrEqual","before","beforeOrEqual"].includes(i)&&(r=new Date(parseInt(r)).toLocaleTimeString(this.locale,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"numeric",hour12:!1}));let n=[null,void 0,""].includes(r)?this.messages[i]:this.messages[i].replace("[PARAM]",r);return[null,void 0,""].includes(s)?n.replace("[FIELD]",this.default_field_name??"Value"):n.replace("[FIELD]",s)}_missing(){return{valid:!1,rule:"None",error:"Rules exist, but no value was provided to check"}}_prepare(e,t=[]){return t.length?"optional"===t[0]&&this.assertOptional(e)?[]:t.filter(e=>"optional"!==e).map(e=>[e,this._title(e.split(":").shift()),e.split(":").slice(1)]):[]}_title(e){return`${e[0].toUpperCase()}${e.slice(1)}`}_validate(e,t){for(let r in t=this._prepare(e,t))if(!this[`assert${t[r][1]}`].apply(this,[e,t[r][2].join(":")]))return{valid:!1,rule:t[r][0],error:this._error(t[r][0])};return{valid:!0,rule:"",error:""}}assert(e,t){if(Array.isArray(t))return this._validate(e,t);let r=Object.keys(t),s={valid:!0,fields:{}};for(let a=0;a<r.length;a++)s.fields[r[a]]=e.hasOwnProperty(r[a])?this._validate(e[r[a]],t[r[a]]):this._missing(),s.fields[r[a]].valid||(s.valid=!1);return s}assertAfter(e,t){return this._compare(e,t,"more",!1)}assertAfterOrEqual(e,t){return this._compare(e,t,"more",!0)}assertArray(e){return Array.isArray(e)}assertBefore(e,t){return this._compare(e,t,"less",!1)}assertBeforeOrEqual(e,t){return this._compare(e,t,"less",!0)}assertBoolean(e){return[!0,!1].includes(e)}assertDate(e){return e&&"[object Date]"===Object.prototype.toString.call(e)&&!isNaN(e)}assertDifferent(e,t){return e!=t}assertEndsWith(e,t){return this.assertString(e)&&e.endsWith(t)}assertEmail(e){return new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?").test(String(e).toLowerCase())}assertFalsy(e){return[0,"0",!1,"false"].includes(e)}assertIn(e,t){return("string"==typeof t?t.split(","):t).includes(e)}assertInteger(e){return Number.isInteger(e)&&parseInt(e).toString()===e.toString()}assertJson(e){try{return"object"==typeof JSON.parse(e)}catch(e){return!1}}assertMax(e,t){return parseFloat(e)<=t}assertMin(e,t){return parseFloat(e)>=t}assertMaxLength(e,t){return"string"==typeof e&&e.length<=t}assertMinLength(e,t){return"string"==typeof e&&e.length>=t}assertNotIn(e,t){return!this.assertIn(e,t)}assertNumeric(e){return!isNaN(parseFloat(e))&&isFinite(e)}assertOptional(e){return[null,void 0,""].includes(e)}assertRegexMatch(e,t){return new RegExp(t).test(String(e))}assertRequired(e){return!this.assertOptional(e)}assertSame(e,t){return e==t}assertStartsWith(e,t){return this.assertString(e)&&e.startsWith(t)}assertString(e){return"string"==typeof e}assertTruthy(e){return[1,"1",!0,"true"].includes(e)}assertUrl(e){return new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$").test(String(e).toLowerCase())}assertUuid(e){return new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$").test(String(e).toLowerCase())}rule(t,r){e.prototype[`assert${this._title(t)}`]=r}setErrorMessages(e){this.messages=e}setErrorMessage(e,t){this.messages[e]=t}setLocale(e){this.locale=e}setDefaultFieldName(e){this.default_field_name=e}}"undefined"!=typeof window&&(window.Iodine=new e);export{e as default};
class e{constructor(){this.locale=void 0,this.messages={after:"The date must be after: '[PARAM]'",afterOrEqual:"The date must be after or equal to: '[PARAM]'",array:"[FIELD] must be an array",before:"The date must be before: '[PARAM]'",beforeOrEqual:"The date must be before or equal to: '[PARAM]'",boolean:"[FIELD] must be true or false",date:"[FIELD] must be a date",different:"[FIELD] must be different to '[PARAM]'",endsWith:"[FIELD] must end with '[PARAM]'",email:"[FIELD] must be a valid email address",falsy:"[FIELD] must be a falsy value (false, 'false', 0 or '0')",in:"[FIELD] must be one of the following options: [PARAM]",integer:"[FIELD] must be an integer",json:"[FIELD] must be a parsable JSON object string",max:"[FIELD] must be less than or equal to [PARAM]",min:"[FIELD] must be greater than or equal to [PARAM]",maxLength:"[FIELD] must not be greater than '[PARAM]' in character length",minLength:"[FIELD] must not be less than '[PARAM]' character length",notIn:"[FIELD] must not be one of the following options: [PARAM]",numeric:"[FIELD] must be numeric",optional:"[FIELD] is optional",regexMatch:"[FIELD] must satisify the regular expression: [PARAM]",required:"[FIELD] must be present",same:"[FIELD] must be '[PARAM]'",startsWith:"[FIELD] must start with '[PARAM]'",string:"[FIELD] must be a string",truthy:"[FIELD] must be a truthy value (true, 'true', 1 or '1')",url:"[FIELD] must be a valid url",uuid:"[FIELD] must be a valid UUID"}}_compare(e,t,r,s=!1){return!!this.assertDate(e)&&!(!this.assertDate(t)&&!this.assertInteger(t))&&(t="number"==typeof t?t:t.getTime(),"less"===r&&s?e.getTime()<=t:"less"!==r||s?"more"===r&&s?e.getTime()>=t:"more"!==r||s?void 0:e.getTime()>t:e.getTime()<t)}_error(e,t){let{param:r,field:s}="object"==typeof t?t:{param:t,field:void 0};const a=e.split(":");let i=a.shift();r=r||a.join(":"),["after","afterOrEqual","before","beforeOrEqual"].includes(i)&&(r=new Date(parseInt(r)).toLocaleTimeString(this.locale,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"numeric",hour12:!1}));let n=[null,void 0,""].includes(r)?this.messages[i]:this.messages[i].replace("[PARAM]",r);return[null,void 0,""].includes(s)?n.replace("[FIELD]",this.default_field_name??"Value"):n.replace("[FIELD]",s)}_missing(){return{valid:!1,rule:"None",error:"Rules exist, but no value was provided to check"}}_prepare(e,t=[]){return t.length?"optional"===t[0]&&this.assertOptional(e)?[]:t.filter(e=>"optional"!==e).map(e=>[e,this._title(e.split(":").shift()),e.split(":").slice(1)]):[]}_title(e){return`${e[0].toUpperCase()}${e.slice(1)}`}_validate(e,t){for(let r in t=this._prepare(e,t))if(!this[`assert${t[r][1]}`].apply(this,[e,t[r][2].join(":")]))return{valid:!1,rule:t[r][0],error:this._error(t[r][0])};return{valid:!0,rule:"",error:""}}assert(e,t){if(Array.isArray(t))return this._validate(e,t);let r=Object.keys(t),s={valid:!0,fields:{}};for(let a=0;a<r.length;a++)s.fields[r[a]]=e.hasOwnProperty(r[a])?this._validate(e[r[a]],t[r[a]]):this._missing(),s.fields[r[a]].valid||(s.valid=!1);return s}assertAfter(e,t){return this._compare(e,t,"more",!1)}assertAfterOrEqual(e,t){return this._compare(e,t,"more",!0)}assertArray(e){return Array.isArray(e)}assertBefore(e,t){return this._compare(e,t,"less",!1)}assertBeforeOrEqual(e,t){return this._compare(e,t,"less",!0)}assertBoolean(e){return[!0,!1].includes(e)}assertDate(e){return e&&"[object Date]"===Object.prototype.toString.call(e)&&!isNaN(e)}assertDifferent(e,t){return e!=t}assertEndsWith(e,t){return this.assertString(e)&&e.endsWith(t)}assertEmail(e){return new RegExp("^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$").test(String(e).toLowerCase())}assertFalsy(e){return[0,"0",!1,"false"].includes(e)}assertIn(e,t){return("string"==typeof t?t.split(","):t).includes(e)}assertInteger(e){return Number.isInteger(e)&&parseInt(e).toString()===e.toString()}assertJson(e){try{return"object"==typeof JSON.parse(e)}catch(e){return!1}}assertMax(e,t){return parseFloat(e)<=t}assertMin(e,t){return parseFloat(e)>=t}assertMaxLength(e,t){return"string"==typeof e&&e.length<=t}assertMinLength(e,t){return"string"==typeof e&&e.length>=t}assertNotIn(e,t){return!this.assertIn(e,t)}assertNumeric(e){return!isNaN(parseFloat(e))&&isFinite(e)}assertOptional(e){return[null,void 0,""].includes(e)}assertRegexMatch(e,t){return new RegExp(t).test(String(e))}assertRequired(e){return!this.assertOptional(e)}assertSame(e,t){return e==t}assertStartsWith(e,t){return this.assertString(e)&&e.startsWith(t)}assertString(e){return"string"==typeof e}assertTruthy(e){return[1,"1",!0,"true"].includes(e)}assertUrl(e){return new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$").test(String(e).toLowerCase())}assertUuid(e){return new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$").test(String(e).toLowerCase())}rule(t,r){e.prototype[`assert${this._title(t)}`]=r}setErrorMessages(e){this.messages=e}setErrorMessage(e,t){this.messages[e]=t}setLocale(e){this.locale=e}setDefaultFieldName(e){this.default_field_name=e}}"undefined"!=typeof window&&(window.Iodine=new e);export{e as default};
//# sourceMappingURL=iodine.min.esm.js.map

@@ -1,2 +0,2 @@

class e{constructor(){this.locale=void 0,this.messages={after:"The date must be after: '[PARAM]'",afterOrEqual:"The date must be after or equal to: '[PARAM]'",array:"[FIELD] must be an array",before:"The date must be before: '[PARAM]'",beforeOrEqual:"The date must be before or equal to: '[PARAM]'",boolean:"[FIELD] must be true or false",date:"[FIELD] must be a date",different:"[FIELD] must be different to '[PARAM]'",endsWith:"[FIELD] must end with '[PARAM]'",email:"[FIELD] must be a valid email address",falsy:"[FIELD] must be a falsy value (false, 'false', 0 or '0')",in:"[FIELD] must be one of the following options: [PARAM]",integer:"[FIELD] must be an integer",json:"[FIELD] must be a parsable JSON object string",max:"[FIELD] must be less than or equal to [PARAM]",min:"[FIELD] must be greater than or equal to [PARAM]",maxLength:"[FIELD] must not be greater than '[PARAM]' in character length",minLength:"[FIELD] must not be less than '[PARAM]' character length",notIn:"[FIELD] must not be one of the following options: [PARAM]",numeric:"[FIELD] must be numeric",optional:"[FIELD] is optional",regexMatch:"[FIELD] must satisify the regular expression: [PARAM]",required:"[FIELD] must be present",same:"[FIELD] must be '[PARAM]'",startsWith:"[FIELD] must start with '[PARAM]'",string:"[FIELD] must be a string",truthy:"[FIELD] must be a truthy value (true, 'true', 1 or '1')",url:"[FIELD] must be a valid url",uuid:"[FIELD] must be a valid UUID"}}_compare(e,t,r,s=!1){return!!this.assertDate(e)&&!(!this.assertDate(t)&&!this.assertInteger(t))&&(t="number"==typeof t?t:t.getTime(),"less"===r&&s?e.getTime()<=t:"less"!==r||s?"more"===r&&s?e.getTime()>=t:"more"!==r||s?void 0:e.getTime()>t:e.getTime()<t)}_error(e,t){let{param:r,field:s}="object"==typeof t?t:{param:t,field:void 0};const a=e.split(":");let i=a.shift();r=r||a.join(":"),["after","afterOrEqual","before","beforeOrEqual"].includes(i)&&(r=new Date(parseInt(r)).toLocaleTimeString(this.locale,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"numeric",hour12:!1}));let n=[null,void 0,""].includes(r)?this.messages[i]:this.messages[i].replace("[PARAM]",r);return[null,void 0,""].includes(s)?n.replace("[FIELD]",this.default_field_name??"Value"):n.replace("[FIELD]",s)}_missing(){return{valid:!1,rule:"None",error:"Rules exist, but no value was provided to check"}}_prepare(e,t=[]){return t.length?"optional"===t[0]&&this.assertOptional(e)?[]:t.filter(e=>"optional"!==e).map(e=>[e,this._title(e.split(":").shift()),e.split(":").slice(1)]):[]}_title(e){return`${e[0].toUpperCase()}${e.slice(1)}`}_validate(e,t){for(let r in t=this._prepare(e,t))if(!this[`assert${t[r][1]}`].apply(this,[e,t[r][2].join(":")]))return{valid:!1,rule:t[r][0],error:this._error(t[r][0])};return{valid:!0,rule:"",error:""}}assert(e,t){if(Array.isArray(t))return this._validate(e,t);let r=Object.keys(t),s={valid:!0,fields:{}};for(let a=0;a<r.length;a++)s.fields[r[a]]=e.hasOwnProperty(r[a])?this._validate(e[r[a]],t[r[a]]):this._missing(),s.fields[r[a]].valid||(s.valid=!1);return s}assertAfter(e,t){return this._compare(e,t,"more",!1)}assertAfterOrEqual(e,t){return this._compare(e,t,"more",!0)}assertArray(e){return Array.isArray(e)}assertBefore(e,t){return this._compare(e,t,"less",!1)}assertBeforeOrEqual(e,t){return this._compare(e,t,"less",!0)}assertBoolean(e){return[!0,!1].includes(e)}assertDate(e){return e&&"[object Date]"===Object.prototype.toString.call(e)&&!isNaN(e)}assertDifferent(e,t){return e!=t}assertEndsWith(e,t){return this.assertString(e)&&e.endsWith(t)}assertEmail(e){return new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?").test(String(e).toLowerCase())}assertFalsy(e){return[0,"0",!1,"false"].includes(e)}assertIn(e,t){return("string"==typeof t?t.split(","):t).includes(e)}assertInteger(e){return Number.isInteger(e)&&parseInt(e).toString()===e.toString()}assertJson(e){try{return"object"==typeof JSON.parse(e)}catch(e){return!1}}assertMax(e,t){return parseFloat(e)<=t}assertMin(e,t){return parseFloat(e)>=t}assertMaxLength(e,t){return"string"==typeof e&&e.length<=t}assertMinLength(e,t){return"string"==typeof e&&e.length>=t}assertNotIn(e,t){return!this.assertIn(e,t)}assertNumeric(e){return!isNaN(parseFloat(e))&&isFinite(e)}assertOptional(e){return[null,void 0,""].includes(e)}assertRegexMatch(e,t){return new RegExp(t).test(String(e))}assertRequired(e){return!this.assertOptional(e)}assertSame(e,t){return e==t}assertStartsWith(e,t){return this.assertString(e)&&e.startsWith(t)}assertString(e){return"string"==typeof e}assertTruthy(e){return[1,"1",!0,"true"].includes(e)}assertUrl(e){return new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$").test(String(e).toLowerCase())}assertUuid(e){return new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$").test(String(e).toLowerCase())}rule(t,r){e.prototype[`assert${this._title(t)}`]=r}setErrorMessages(e){this.messages=e}setErrorMessage(e,t){this.messages[e]=t}setLocale(e){this.locale=e}setDefaultFieldName(e){this.default_field_name=e}}"undefined"!=typeof window&&(window.Iodine=new e),module.exports=e;
class e{constructor(){this.locale=void 0,this.messages={after:"The date must be after: '[PARAM]'",afterOrEqual:"The date must be after or equal to: '[PARAM]'",array:"[FIELD] must be an array",before:"The date must be before: '[PARAM]'",beforeOrEqual:"The date must be before or equal to: '[PARAM]'",boolean:"[FIELD] must be true or false",date:"[FIELD] must be a date",different:"[FIELD] must be different to '[PARAM]'",endsWith:"[FIELD] must end with '[PARAM]'",email:"[FIELD] must be a valid email address",falsy:"[FIELD] must be a falsy value (false, 'false', 0 or '0')",in:"[FIELD] must be one of the following options: [PARAM]",integer:"[FIELD] must be an integer",json:"[FIELD] must be a parsable JSON object string",max:"[FIELD] must be less than or equal to [PARAM]",min:"[FIELD] must be greater than or equal to [PARAM]",maxLength:"[FIELD] must not be greater than '[PARAM]' in character length",minLength:"[FIELD] must not be less than '[PARAM]' character length",notIn:"[FIELD] must not be one of the following options: [PARAM]",numeric:"[FIELD] must be numeric",optional:"[FIELD] is optional",regexMatch:"[FIELD] must satisify the regular expression: [PARAM]",required:"[FIELD] must be present",same:"[FIELD] must be '[PARAM]'",startsWith:"[FIELD] must start with '[PARAM]'",string:"[FIELD] must be a string",truthy:"[FIELD] must be a truthy value (true, 'true', 1 or '1')",url:"[FIELD] must be a valid url",uuid:"[FIELD] must be a valid UUID"}}_compare(e,t,r,s=!1){return!!this.assertDate(e)&&!(!this.assertDate(t)&&!this.assertInteger(t))&&(t="number"==typeof t?t:t.getTime(),"less"===r&&s?e.getTime()<=t:"less"!==r||s?"more"===r&&s?e.getTime()>=t:"more"!==r||s?void 0:e.getTime()>t:e.getTime()<t)}_error(e,t){let{param:r,field:s}="object"==typeof t?t:{param:t,field:void 0};const a=e.split(":");let i=a.shift();r=r||a.join(":"),["after","afterOrEqual","before","beforeOrEqual"].includes(i)&&(r=new Date(parseInt(r)).toLocaleTimeString(this.locale,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"numeric",hour12:!1}));let n=[null,void 0,""].includes(r)?this.messages[i]:this.messages[i].replace("[PARAM]",r);return[null,void 0,""].includes(s)?n.replace("[FIELD]",this.default_field_name??"Value"):n.replace("[FIELD]",s)}_missing(){return{valid:!1,rule:"None",error:"Rules exist, but no value was provided to check"}}_prepare(e,t=[]){return t.length?"optional"===t[0]&&this.assertOptional(e)?[]:t.filter(e=>"optional"!==e).map(e=>[e,this._title(e.split(":").shift()),e.split(":").slice(1)]):[]}_title(e){return`${e[0].toUpperCase()}${e.slice(1)}`}_validate(e,t){for(let r in t=this._prepare(e,t))if(!this[`assert${t[r][1]}`].apply(this,[e,t[r][2].join(":")]))return{valid:!1,rule:t[r][0],error:this._error(t[r][0])};return{valid:!0,rule:"",error:""}}assert(e,t){if(Array.isArray(t))return this._validate(e,t);let r=Object.keys(t),s={valid:!0,fields:{}};for(let a=0;a<r.length;a++)s.fields[r[a]]=e.hasOwnProperty(r[a])?this._validate(e[r[a]],t[r[a]]):this._missing(),s.fields[r[a]].valid||(s.valid=!1);return s}assertAfter(e,t){return this._compare(e,t,"more",!1)}assertAfterOrEqual(e,t){return this._compare(e,t,"more",!0)}assertArray(e){return Array.isArray(e)}assertBefore(e,t){return this._compare(e,t,"less",!1)}assertBeforeOrEqual(e,t){return this._compare(e,t,"less",!0)}assertBoolean(e){return[!0,!1].includes(e)}assertDate(e){return e&&"[object Date]"===Object.prototype.toString.call(e)&&!isNaN(e)}assertDifferent(e,t){return e!=t}assertEndsWith(e,t){return this.assertString(e)&&e.endsWith(t)}assertEmail(e){return new RegExp("^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$").test(String(e).toLowerCase())}assertFalsy(e){return[0,"0",!1,"false"].includes(e)}assertIn(e,t){return("string"==typeof t?t.split(","):t).includes(e)}assertInteger(e){return Number.isInteger(e)&&parseInt(e).toString()===e.toString()}assertJson(e){try{return"object"==typeof JSON.parse(e)}catch(e){return!1}}assertMax(e,t){return parseFloat(e)<=t}assertMin(e,t){return parseFloat(e)>=t}assertMaxLength(e,t){return"string"==typeof e&&e.length<=t}assertMinLength(e,t){return"string"==typeof e&&e.length>=t}assertNotIn(e,t){return!this.assertIn(e,t)}assertNumeric(e){return!isNaN(parseFloat(e))&&isFinite(e)}assertOptional(e){return[null,void 0,""].includes(e)}assertRegexMatch(e,t){return new RegExp(t).test(String(e))}assertRequired(e){return!this.assertOptional(e)}assertSame(e,t){return e==t}assertStartsWith(e,t){return this.assertString(e)&&e.startsWith(t)}assertString(e){return"string"==typeof e}assertTruthy(e){return[1,"1",!0,"true"].includes(e)}assertUrl(e){return new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$").test(String(e).toLowerCase())}assertUuid(e){return new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$").test(String(e).toLowerCase())}rule(t,r){e.prototype[`assert${this._title(t)}`]=r}setErrorMessages(e){this.messages=e}setErrorMessage(e,t){this.messages[e]=t}setLocale(e){this.locale=e}setDefaultFieldName(e){this.default_field_name=e}}"undefined"!=typeof window&&(window.Iodine=new e),module.exports=e;
//# sourceMappingURL=iodine.min.js.map

@@ -1,2 +0,2 @@

class e{constructor(){this.locale=void 0,this.messages={after:"The date must be after: '[PARAM]'",afterOrEqual:"The date must be after or equal to: '[PARAM]'",array:"[FIELD] must be an array",before:"The date must be before: '[PARAM]'",beforeOrEqual:"The date must be before or equal to: '[PARAM]'",boolean:"[FIELD] must be true or false",date:"[FIELD] must be a date",different:"[FIELD] must be different to '[PARAM]'",endsWith:"[FIELD] must end with '[PARAM]'",email:"[FIELD] must be a valid email address",falsy:"[FIELD] must be a falsy value (false, 'false', 0 or '0')",in:"[FIELD] must be one of the following options: [PARAM]",integer:"[FIELD] must be an integer",json:"[FIELD] must be a parsable JSON object string",max:"[FIELD] must be less than or equal to [PARAM]",min:"[FIELD] must be greater than or equal to [PARAM]",maxLength:"[FIELD] must not be greater than '[PARAM]' in character length",minLength:"[FIELD] must not be less than '[PARAM]' character length",notIn:"[FIELD] must not be one of the following options: [PARAM]",numeric:"[FIELD] must be numeric",optional:"[FIELD] is optional",regexMatch:"[FIELD] must satisify the regular expression: [PARAM]",required:"[FIELD] must be present",same:"[FIELD] must be '[PARAM]'",startsWith:"[FIELD] must start with '[PARAM]'",string:"[FIELD] must be a string",truthy:"[FIELD] must be a truthy value (true, 'true', 1 or '1')",url:"[FIELD] must be a valid url",uuid:"[FIELD] must be a valid UUID"}}_compare(e,t,r,s=!1){return!!this.assertDate(e)&&!(!this.assertDate(t)&&!this.assertInteger(t))&&(t="number"==typeof t?t:t.getTime(),"less"===r&&s?e.getTime()<=t:"less"!==r||s?"more"===r&&s?e.getTime()>=t:"more"!==r||s?void 0:e.getTime()>t:e.getTime()<t)}_error(e,t){var r;let{param:s,field:a}="object"==typeof t?t:{param:t,field:void 0};const i=e.split(":");let n=i.shift();s=s||i.join(":"),["after","afterOrEqual","before","beforeOrEqual"].includes(n)&&(s=new Date(parseInt(s)).toLocaleTimeString(this.locale,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"numeric",hour12:!1}));let l=[null,void 0,""].includes(s)?this.messages[n]:this.messages[n].replace("[PARAM]",s);return[null,void 0,""].includes(a)?l.replace("[FIELD]",null!=(r=this.default_field_name)?r:"Value"):l.replace("[FIELD]",a)}_missing(){return{valid:!1,rule:"None",error:"Rules exist, but no value was provided to check"}}_prepare(e,t=[]){return t.length?"optional"===t[0]&&this.assertOptional(e)?[]:t.filter(e=>"optional"!==e).map(e=>[e,this._title(e.split(":").shift()),e.split(":").slice(1)]):[]}_title(e){return`${e[0].toUpperCase()}${e.slice(1)}`}_validate(e,t){for(let r in t=this._prepare(e,t))if(!this[`assert${t[r][1]}`].apply(this,[e,t[r][2].join(":")]))return{valid:!1,rule:t[r][0],error:this._error(t[r][0])};return{valid:!0,rule:"",error:""}}assert(e,t){if(Array.isArray(t))return this._validate(e,t);let r=Object.keys(t),s={valid:!0,fields:{}};for(let a=0;a<r.length;a++)s.fields[r[a]]=e.hasOwnProperty(r[a])?this._validate(e[r[a]],t[r[a]]):this._missing(),s.fields[r[a]].valid||(s.valid=!1);return s}assertAfter(e,t){return this._compare(e,t,"more",!1)}assertAfterOrEqual(e,t){return this._compare(e,t,"more",!0)}assertArray(e){return Array.isArray(e)}assertBefore(e,t){return this._compare(e,t,"less",!1)}assertBeforeOrEqual(e,t){return this._compare(e,t,"less",!0)}assertBoolean(e){return[!0,!1].includes(e)}assertDate(e){return e&&"[object Date]"===Object.prototype.toString.call(e)&&!isNaN(e)}assertDifferent(e,t){return e!=t}assertEndsWith(e,t){return this.assertString(e)&&e.endsWith(t)}assertEmail(e){return new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?").test(String(e).toLowerCase())}assertFalsy(e){return[0,"0",!1,"false"].includes(e)}assertIn(e,t){return("string"==typeof t?t.split(","):t).includes(e)}assertInteger(e){return Number.isInteger(e)&&parseInt(e).toString()===e.toString()}assertJson(e){try{return"object"==typeof JSON.parse(e)}catch(e){return!1}}assertMax(e,t){return parseFloat(e)<=t}assertMin(e,t){return parseFloat(e)>=t}assertMaxLength(e,t){return"string"==typeof e&&e.length<=t}assertMinLength(e,t){return"string"==typeof e&&e.length>=t}assertNotIn(e,t){return!this.assertIn(e,t)}assertNumeric(e){return!isNaN(parseFloat(e))&&isFinite(e)}assertOptional(e){return[null,void 0,""].includes(e)}assertRegexMatch(e,t){return new RegExp(t).test(String(e))}assertRequired(e){return!this.assertOptional(e)}assertSame(e,t){return e==t}assertStartsWith(e,t){return this.assertString(e)&&e.startsWith(t)}assertString(e){return"string"==typeof e}assertTruthy(e){return[1,"1",!0,"true"].includes(e)}assertUrl(e){return new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$").test(String(e).toLowerCase())}assertUuid(e){return new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$").test(String(e).toLowerCase())}rule(t,r){e.prototype[`assert${this._title(t)}`]=r}setErrorMessages(e){this.messages=e}setErrorMessage(e,t){this.messages[e]=t}setLocale(e){this.locale=e}setDefaultFieldName(e){this.default_field_name=e}}"undefined"!=typeof window&&(window.Iodine=new e);export{e as default};
class e{constructor(){this.locale=void 0,this.messages={after:"The date must be after: '[PARAM]'",afterOrEqual:"The date must be after or equal to: '[PARAM]'",array:"[FIELD] must be an array",before:"The date must be before: '[PARAM]'",beforeOrEqual:"The date must be before or equal to: '[PARAM]'",boolean:"[FIELD] must be true or false",date:"[FIELD] must be a date",different:"[FIELD] must be different to '[PARAM]'",endsWith:"[FIELD] must end with '[PARAM]'",email:"[FIELD] must be a valid email address",falsy:"[FIELD] must be a falsy value (false, 'false', 0 or '0')",in:"[FIELD] must be one of the following options: [PARAM]",integer:"[FIELD] must be an integer",json:"[FIELD] must be a parsable JSON object string",max:"[FIELD] must be less than or equal to [PARAM]",min:"[FIELD] must be greater than or equal to [PARAM]",maxLength:"[FIELD] must not be greater than '[PARAM]' in character length",minLength:"[FIELD] must not be less than '[PARAM]' character length",notIn:"[FIELD] must not be one of the following options: [PARAM]",numeric:"[FIELD] must be numeric",optional:"[FIELD] is optional",regexMatch:"[FIELD] must satisify the regular expression: [PARAM]",required:"[FIELD] must be present",same:"[FIELD] must be '[PARAM]'",startsWith:"[FIELD] must start with '[PARAM]'",string:"[FIELD] must be a string",truthy:"[FIELD] must be a truthy value (true, 'true', 1 or '1')",url:"[FIELD] must be a valid url",uuid:"[FIELD] must be a valid UUID"}}_compare(e,t,r,s=!1){return!!this.assertDate(e)&&!(!this.assertDate(t)&&!this.assertInteger(t))&&(t="number"==typeof t?t:t.getTime(),"less"===r&&s?e.getTime()<=t:"less"!==r||s?"more"===r&&s?e.getTime()>=t:"more"!==r||s?void 0:e.getTime()>t:e.getTime()<t)}_error(e,t){var r;let{param:s,field:a}="object"==typeof t?t:{param:t,field:void 0};const i=e.split(":");let n=i.shift();s=s||i.join(":"),["after","afterOrEqual","before","beforeOrEqual"].includes(n)&&(s=new Date(parseInt(s)).toLocaleTimeString(this.locale,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"numeric",hour12:!1}));let l=[null,void 0,""].includes(s)?this.messages[n]:this.messages[n].replace("[PARAM]",s);return[null,void 0,""].includes(a)?l.replace("[FIELD]",null!=(r=this.default_field_name)?r:"Value"):l.replace("[FIELD]",a)}_missing(){return{valid:!1,rule:"None",error:"Rules exist, but no value was provided to check"}}_prepare(e,t=[]){return t.length?"optional"===t[0]&&this.assertOptional(e)?[]:t.filter(e=>"optional"!==e).map(e=>[e,this._title(e.split(":").shift()),e.split(":").slice(1)]):[]}_title(e){return`${e[0].toUpperCase()}${e.slice(1)}`}_validate(e,t){for(let r in t=this._prepare(e,t))if(!this[`assert${t[r][1]}`].apply(this,[e,t[r][2].join(":")]))return{valid:!1,rule:t[r][0],error:this._error(t[r][0])};return{valid:!0,rule:"",error:""}}assert(e,t){if(Array.isArray(t))return this._validate(e,t);let r=Object.keys(t),s={valid:!0,fields:{}};for(let a=0;a<r.length;a++)s.fields[r[a]]=e.hasOwnProperty(r[a])?this._validate(e[r[a]],t[r[a]]):this._missing(),s.fields[r[a]].valid||(s.valid=!1);return s}assertAfter(e,t){return this._compare(e,t,"more",!1)}assertAfterOrEqual(e,t){return this._compare(e,t,"more",!0)}assertArray(e){return Array.isArray(e)}assertBefore(e,t){return this._compare(e,t,"less",!1)}assertBeforeOrEqual(e,t){return this._compare(e,t,"less",!0)}assertBoolean(e){return[!0,!1].includes(e)}assertDate(e){return e&&"[object Date]"===Object.prototype.toString.call(e)&&!isNaN(e)}assertDifferent(e,t){return e!=t}assertEndsWith(e,t){return this.assertString(e)&&e.endsWith(t)}assertEmail(e){return new RegExp("^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$").test(String(e).toLowerCase())}assertFalsy(e){return[0,"0",!1,"false"].includes(e)}assertIn(e,t){return("string"==typeof t?t.split(","):t).includes(e)}assertInteger(e){return Number.isInteger(e)&&parseInt(e).toString()===e.toString()}assertJson(e){try{return"object"==typeof JSON.parse(e)}catch(e){return!1}}assertMax(e,t){return parseFloat(e)<=t}assertMin(e,t){return parseFloat(e)>=t}assertMaxLength(e,t){return"string"==typeof e&&e.length<=t}assertMinLength(e,t){return"string"==typeof e&&e.length>=t}assertNotIn(e,t){return!this.assertIn(e,t)}assertNumeric(e){return!isNaN(parseFloat(e))&&isFinite(e)}assertOptional(e){return[null,void 0,""].includes(e)}assertRegexMatch(e,t){return new RegExp(t).test(String(e))}assertRequired(e){return!this.assertOptional(e)}assertSame(e,t){return e==t}assertStartsWith(e,t){return this.assertString(e)&&e.startsWith(t)}assertString(e){return"string"==typeof e}assertTruthy(e){return[1,"1",!0,"true"].includes(e)}assertUrl(e){return new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$").test(String(e).toLowerCase())}assertUuid(e){return new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$").test(String(e).toLowerCase())}rule(t,r){e.prototype[`assert${this._title(t)}`]=r}setErrorMessages(e){this.messages=e}setErrorMessage(e,t){this.messages[e]=t}setLocale(e){this.locale=e}setDefaultFieldName(e){this.default_field_name=e}}"undefined"!=typeof window&&(window.Iodine=new e);export{e as default};
//# sourceMappingURL=iodine.min.modern.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).iodine=t()}(this,function(){class e{constructor(){this.locale=void 0,this.messages={after:"The date must be after: '[PARAM]'",afterOrEqual:"The date must be after or equal to: '[PARAM]'",array:"[FIELD] must be an array",before:"The date must be before: '[PARAM]'",beforeOrEqual:"The date must be before or equal to: '[PARAM]'",boolean:"[FIELD] must be true or false",date:"[FIELD] must be a date",different:"[FIELD] must be different to '[PARAM]'",endsWith:"[FIELD] must end with '[PARAM]'",email:"[FIELD] must be a valid email address",falsy:"[FIELD] must be a falsy value (false, 'false', 0 or '0')",in:"[FIELD] must be one of the following options: [PARAM]",integer:"[FIELD] must be an integer",json:"[FIELD] must be a parsable JSON object string",max:"[FIELD] must be less than or equal to [PARAM]",min:"[FIELD] must be greater than or equal to [PARAM]",maxLength:"[FIELD] must not be greater than '[PARAM]' in character length",minLength:"[FIELD] must not be less than '[PARAM]' character length",notIn:"[FIELD] must not be one of the following options: [PARAM]",numeric:"[FIELD] must be numeric",optional:"[FIELD] is optional",regexMatch:"[FIELD] must satisify the regular expression: [PARAM]",required:"[FIELD] must be present",same:"[FIELD] must be '[PARAM]'",startsWith:"[FIELD] must start with '[PARAM]'",string:"[FIELD] must be a string",truthy:"[FIELD] must be a truthy value (true, 'true', 1 or '1')",url:"[FIELD] must be a valid url",uuid:"[FIELD] must be a valid UUID"}}_compare(e,t,r,s=!1){return!!this.assertDate(e)&&!(!this.assertDate(t)&&!this.assertInteger(t))&&(t="number"==typeof t?t:t.getTime(),"less"===r&&s?e.getTime()<=t:"less"!==r||s?"more"===r&&s?e.getTime()>=t:"more"!==r||s?void 0:e.getTime()>t:e.getTime()<t)}_error(e,t){let{param:r,field:s}="object"==typeof t?t:{param:t,field:void 0};const a=e.split(":");let i=a.shift();r=r||a.join(":"),["after","afterOrEqual","before","beforeOrEqual"].includes(i)&&(r=new Date(parseInt(r)).toLocaleTimeString(this.locale,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"numeric",hour12:!1}));let n=[null,void 0,""].includes(r)?this.messages[i]:this.messages[i].replace("[PARAM]",r);return[null,void 0,""].includes(s)?n.replace("[FIELD]",this.default_field_name??"Value"):n.replace("[FIELD]",s)}_missing(){return{valid:!1,rule:"None",error:"Rules exist, but no value was provided to check"}}_prepare(e,t=[]){return t.length?"optional"===t[0]&&this.assertOptional(e)?[]:t.filter(e=>"optional"!==e).map(e=>[e,this._title(e.split(":").shift()),e.split(":").slice(1)]):[]}_title(e){return`${e[0].toUpperCase()}${e.slice(1)}`}_validate(e,t){for(let r in t=this._prepare(e,t))if(!this[`assert${t[r][1]}`].apply(this,[e,t[r][2].join(":")]))return{valid:!1,rule:t[r][0],error:this._error(t[r][0])};return{valid:!0,rule:"",error:""}}assert(e,t){if(Array.isArray(t))return this._validate(e,t);let r=Object.keys(t),s={valid:!0,fields:{}};for(let a=0;a<r.length;a++)s.fields[r[a]]=e.hasOwnProperty(r[a])?this._validate(e[r[a]],t[r[a]]):this._missing(),s.fields[r[a]].valid||(s.valid=!1);return s}assertAfter(e,t){return this._compare(e,t,"more",!1)}assertAfterOrEqual(e,t){return this._compare(e,t,"more",!0)}assertArray(e){return Array.isArray(e)}assertBefore(e,t){return this._compare(e,t,"less",!1)}assertBeforeOrEqual(e,t){return this._compare(e,t,"less",!0)}assertBoolean(e){return[!0,!1].includes(e)}assertDate(e){return e&&"[object Date]"===Object.prototype.toString.call(e)&&!isNaN(e)}assertDifferent(e,t){return e!=t}assertEndsWith(e,t){return this.assertString(e)&&e.endsWith(t)}assertEmail(e){return new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?").test(String(e).toLowerCase())}assertFalsy(e){return[0,"0",!1,"false"].includes(e)}assertIn(e,t){return("string"==typeof t?t.split(","):t).includes(e)}assertInteger(e){return Number.isInteger(e)&&parseInt(e).toString()===e.toString()}assertJson(e){try{return"object"==typeof JSON.parse(e)}catch(e){return!1}}assertMax(e,t){return parseFloat(e)<=t}assertMin(e,t){return parseFloat(e)>=t}assertMaxLength(e,t){return"string"==typeof e&&e.length<=t}assertMinLength(e,t){return"string"==typeof e&&e.length>=t}assertNotIn(e,t){return!this.assertIn(e,t)}assertNumeric(e){return!isNaN(parseFloat(e))&&isFinite(e)}assertOptional(e){return[null,void 0,""].includes(e)}assertRegexMatch(e,t){return new RegExp(t).test(String(e))}assertRequired(e){return!this.assertOptional(e)}assertSame(e,t){return e==t}assertStartsWith(e,t){return this.assertString(e)&&e.startsWith(t)}assertString(e){return"string"==typeof e}assertTruthy(e){return[1,"1",!0,"true"].includes(e)}assertUrl(e){return new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$").test(String(e).toLowerCase())}assertUuid(e){return new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$").test(String(e).toLowerCase())}rule(t,r){e.prototype[`assert${this._title(t)}`]=r}setErrorMessages(e){this.messages=e}setErrorMessage(e,t){this.messages[e]=t}setLocale(e){this.locale=e}setDefaultFieldName(e){this.default_field_name=e}}return"undefined"!=typeof window&&(window.Iodine=new e),e});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).iodine=t()}(this,function(){class e{constructor(){this.locale=void 0,this.messages={after:"The date must be after: '[PARAM]'",afterOrEqual:"The date must be after or equal to: '[PARAM]'",array:"[FIELD] must be an array",before:"The date must be before: '[PARAM]'",beforeOrEqual:"The date must be before or equal to: '[PARAM]'",boolean:"[FIELD] must be true or false",date:"[FIELD] must be a date",different:"[FIELD] must be different to '[PARAM]'",endsWith:"[FIELD] must end with '[PARAM]'",email:"[FIELD] must be a valid email address",falsy:"[FIELD] must be a falsy value (false, 'false', 0 or '0')",in:"[FIELD] must be one of the following options: [PARAM]",integer:"[FIELD] must be an integer",json:"[FIELD] must be a parsable JSON object string",max:"[FIELD] must be less than or equal to [PARAM]",min:"[FIELD] must be greater than or equal to [PARAM]",maxLength:"[FIELD] must not be greater than '[PARAM]' in character length",minLength:"[FIELD] must not be less than '[PARAM]' character length",notIn:"[FIELD] must not be one of the following options: [PARAM]",numeric:"[FIELD] must be numeric",optional:"[FIELD] is optional",regexMatch:"[FIELD] must satisify the regular expression: [PARAM]",required:"[FIELD] must be present",same:"[FIELD] must be '[PARAM]'",startsWith:"[FIELD] must start with '[PARAM]'",string:"[FIELD] must be a string",truthy:"[FIELD] must be a truthy value (true, 'true', 1 or '1')",url:"[FIELD] must be a valid url",uuid:"[FIELD] must be a valid UUID"}}_compare(e,t,r,s=!1){return!!this.assertDate(e)&&!(!this.assertDate(t)&&!this.assertInteger(t))&&(t="number"==typeof t?t:t.getTime(),"less"===r&&s?e.getTime()<=t:"less"!==r||s?"more"===r&&s?e.getTime()>=t:"more"!==r||s?void 0:e.getTime()>t:e.getTime()<t)}_error(e,t){let{param:r,field:s}="object"==typeof t?t:{param:t,field:void 0};const a=e.split(":");let i=a.shift();r=r||a.join(":"),["after","afterOrEqual","before","beforeOrEqual"].includes(i)&&(r=new Date(parseInt(r)).toLocaleTimeString(this.locale,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"numeric",hour12:!1}));let n=[null,void 0,""].includes(r)?this.messages[i]:this.messages[i].replace("[PARAM]",r);return[null,void 0,""].includes(s)?n.replace("[FIELD]",this.default_field_name??"Value"):n.replace("[FIELD]",s)}_missing(){return{valid:!1,rule:"None",error:"Rules exist, but no value was provided to check"}}_prepare(e,t=[]){return t.length?"optional"===t[0]&&this.assertOptional(e)?[]:t.filter(e=>"optional"!==e).map(e=>[e,this._title(e.split(":").shift()),e.split(":").slice(1)]):[]}_title(e){return`${e[0].toUpperCase()}${e.slice(1)}`}_validate(e,t){for(let r in t=this._prepare(e,t))if(!this[`assert${t[r][1]}`].apply(this,[e,t[r][2].join(":")]))return{valid:!1,rule:t[r][0],error:this._error(t[r][0])};return{valid:!0,rule:"",error:""}}assert(e,t){if(Array.isArray(t))return this._validate(e,t);let r=Object.keys(t),s={valid:!0,fields:{}};for(let a=0;a<r.length;a++)s.fields[r[a]]=e.hasOwnProperty(r[a])?this._validate(e[r[a]],t[r[a]]):this._missing(),s.fields[r[a]].valid||(s.valid=!1);return s}assertAfter(e,t){return this._compare(e,t,"more",!1)}assertAfterOrEqual(e,t){return this._compare(e,t,"more",!0)}assertArray(e){return Array.isArray(e)}assertBefore(e,t){return this._compare(e,t,"less",!1)}assertBeforeOrEqual(e,t){return this._compare(e,t,"less",!0)}assertBoolean(e){return[!0,!1].includes(e)}assertDate(e){return e&&"[object Date]"===Object.prototype.toString.call(e)&&!isNaN(e)}assertDifferent(e,t){return e!=t}assertEndsWith(e,t){return this.assertString(e)&&e.endsWith(t)}assertEmail(e){return new RegExp("^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$").test(String(e).toLowerCase())}assertFalsy(e){return[0,"0",!1,"false"].includes(e)}assertIn(e,t){return("string"==typeof t?t.split(","):t).includes(e)}assertInteger(e){return Number.isInteger(e)&&parseInt(e).toString()===e.toString()}assertJson(e){try{return"object"==typeof JSON.parse(e)}catch(e){return!1}}assertMax(e,t){return parseFloat(e)<=t}assertMin(e,t){return parseFloat(e)>=t}assertMaxLength(e,t){return"string"==typeof e&&e.length<=t}assertMinLength(e,t){return"string"==typeof e&&e.length>=t}assertNotIn(e,t){return!this.assertIn(e,t)}assertNumeric(e){return!isNaN(parseFloat(e))&&isFinite(e)}assertOptional(e){return[null,void 0,""].includes(e)}assertRegexMatch(e,t){return new RegExp(t).test(String(e))}assertRequired(e){return!this.assertOptional(e)}assertSame(e,t){return e==t}assertStartsWith(e,t){return this.assertString(e)&&e.startsWith(t)}assertString(e){return"string"==typeof e}assertTruthy(e){return[1,"1",!0,"true"].includes(e)}assertUrl(e){return new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$").test(String(e).toLowerCase())}assertUuid(e){return new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$").test(String(e).toLowerCase())}rule(t,r){e.prototype[`assert${this._title(t)}`]=r}setErrorMessages(e){this.messages=e}setErrorMessage(e,t){this.messages[e]=t}setLocale(e){this.locale=e}setDefaultFieldName(e){this.default_field_name=e}}return"undefined"!=typeof window&&(window.Iodine=new e),e});
//# sourceMappingURL=iodine.min.umd.js.map
{
"name": "@kingshott/iodine",
"version": "8.2.0",
"version": "8.2.1",
"description": "A micro client-side validation library",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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