elvalidator
Advanced tools
Comparing version 1.7.4 to 1.7.6
@@ -7,2 +7,10 @@ # Changelog | ||
## [1.7.6] - 2022-12-29 | ||
### Fixed | ||
- Builtin Regexes to be compatible with Safari. | ||
## [1.7.5] - 2022-12-28 | ||
### Fixed | ||
- dismissEmptyObjects to apply to top-level object too. | ||
## [1.7.4] - 2022-12-28 | ||
@@ -9,0 +17,0 @@ ### Added |
@@ -1,1 +0,1 @@ | ||
var e={d:(r,t)=>{for(var i in t)e.o(t,i)&&!e.o(r,i)&&Object.defineProperty(r,i,{enumerable:!0,get:t[i]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{Mixed:()=>t,default:()=>i});const t=Symbol("Mixed");class i{constructor(e={},r={}){this.schema=this._checkSchema(e),this.options={strictMode:!0,throwUnkownFields:!1,accumulateErrors:!1,dismissEmptyObjects:!0,...r},this.errors=[]}_checkSchema(e,r="Schema"){if(!i.isObject(e))throw new Error("The schema must be an object.");if(i.hasOwnProperty(e,"$or")){if(!i.isArray(e.$or))throw new Error(r+".$or must be an array.");e.$or=e.$or.map(((e,t)=>this._checkSchema({v:e},r+".$or["+t+"]").v))}else{if(!i.hasOwnProperty(e,"type")||i.isObject(e.type)){for(let t in e){let a=r+"."+t;if(i.isArray(e[t]))e[t]={type:e[t]};else if(!i.isObject(e[t]))throw new Error(a+" must be an object.");e[t]=this._checkSchema(e[t],a)}return e}if(i.isArray(e.type)){if(1!=e.type.length)throw new Error(r+" must have a single item.");e.type=[this._checkSchema({v:e.type[0]},r).v],i.hasOwnProperty(e,"minEntries")&&(e.minEntries=parseInt(e.minEntries)||0),i.hasOwnProperty(e,"maxEntries")&&(e.maxEntries=parseInt(e.maxEntries)||0),i.hasOwnProperty(e,"uniqueValues")&&(e.uniqueValues=!!e.uniqueValues),i.hasOwnProperty(e.type[0],"required")&&(e.required=!!e.type[0].required),e.minEntries&&e.minEntries>0&&(e.required=!0)}else if(e.type===String){if(i.hasOwnProperty(e,"maxLength")&&(e.maxLength=parseInt(e.maxLength)||0),i.hasOwnProperty(e,"minLength")&&(e.minLength=parseInt(e.minLength)||0),i.hasOwnProperty(e,"lowercase")&&(e.lowercase=!!e.lowercase),i.hasOwnProperty(e,"uppercase")&&(e.uppercase=!!e.uppercase),i.hasOwnProperty(e,"trim")&&(e.trim=!!e.trim),i.hasOwnProperty(e,"enum")){if(!i.isArray(e.enum))throw new Error(r+" must have an array value for its enum field.");e.enum=e.enum.map((e=>String(e)))}if(i.hasOwnProperty(e,"match")){if(!(e.match instanceof RegExp))throw new Error(r+' has an invalid RegExp for its "match" field.');e.match=e.match}}else if(e.type===Number){if(i.hasOwnProperty(e,"min")&&(e.min=parseInt(e.min)||0),i.hasOwnProperty(e,"max")&&(e.max=parseInt(e.max)||0),i.hasOwnProperty(e,"integer")&&(e.integer=!!e.integer),i.hasOwnProperty(e,"enum")){if(!i.isArray(e.enum))throw new Error(r+" must have an array value for its enum field.");e.enum=e.enum.map((e=>{if("number"!=typeof e)throw new Error(r+" enum values need to be numbers.");return parseInt(e)}))}}else if(e.type===Boolean);else if(e.type===Object);else{if(e.type!==t)throw new Error(r+' has an invalid value for the "type" field.');if(i.hasOwnProperty(e,"enum")){if(!i.isArray(e.enum))throw new Error(r+" must have an array value for its enum field.");e.enum=e.enum}}}if(i.hasOwnProperty(e,"default")&&(e.default=e.default),i.hasOwnProperty(e,"required")&&(e.required=!!e.required),i.hasOwnProperty(e,"name")&&(e.name=String(e.name)),i.hasOwnProperty(e,"validator")){if("function"!=typeof e.validator)throw new Error(r+' must have a function for the "validator" field.');e.validator=e.validator}return e}async validate(e){this.errors=[];var r=await this._validate(e,this.schema,"");if(this.errors.length>0)throw new Error(this.errors.join("\n"));return r}_error(e){if(!this.options.accumulateErrors)throw new Error(e);this.errors.push(e)}async _validate(e,r,a=""){var s=r.name||a||"Input";if(void 0!==e){if(i.hasOwnProperty(r,"$or")){var n=structuredClone(e),o=(e=void 0,this.errors);let t=[];for(let i in r.$or){this.errors=[],e=void 0;try{if(e=await this._validate(n,r.$or[i],s+".$or["+i+"]"),0==this.errors.length&&void 0!==e)break;t.push(...this.errors),e=void 0}catch(r){e=void 0}}return this.errors=o,void 0===e&&(i.hasOwnProperty(r,"default")?e=r.default:i.hasOwnProperty(r,"required")&&r.required&&this._error('The "'+s+'" field matches none of the possible formats.')),e}switch(r.type){case String:if(!i.isString(e)){if(this.options.strictMode)return void this._error('The "'+s+'" field must be a text value.');e=i.hasOwnProperty(r,"default")&&"number"!=typeof e?r.default:String(e)}r.uppercase&&(e=e.toUpperCase()),r.lowercase&&(e=e.toLowerCase()),r.trim&&(e=e.trim()),i.hasOwnProperty(r,"maxLength")&&e.length>r.maxLength&&(this.options.strictMode?this._error('The "'+s+'" field must be at most '+r.maxLength+" characters long."):e=e.subString(0,r.maxLength)),i.hasOwnProperty(r,"minLength")&&e.length<r.minLength&&this._error('The "'+s+'" field must be at least '+r.minLength+" characters long."),i.hasOwnProperty(r,"enum")&&!r.enum.includes(e)&&this._error('The "'+s+'" field has an invalid value.'),i.hasOwnProperty(r,"match")&&!e.match(r.match)&&this._error('The "'+s+"\" field doesn't match the required format.");break;case Number:if(!i.isNumber(e)){if(this.options.strictMode||!i.hasOwnProperty(r,"default"))return void this._error('The "'+s+'" field must be a number.');e=r.default}i.hasOwnProperty(r,"integer")&&r.integer&&Math.round(e)!=e&&(this.options.strictMode?this._error('The "'+s+'" field must be an integer.'):e=Math.round(e)),i.hasOwnProperty(r,"max")&&e>r.max&&(this.options.strictMode?this._error('The "'+s+'" field must be smaller than "'+r.max+'".'):e=r.max),i.hasOwnProperty(r,"min")&&e<r.min&&(this.options.strictMode?this._error('The "'+s+'" field must be greater than "'+r.min+'".'):e=r.min),i.hasOwnProperty(r,"enum")&&!r.enum.includes(e)&&this._error('The "'+s+'" field has an invalid value.');break;case Boolean:if(!i.isBoolean(e)){if(this.options.strictMode)return void this._error('The "'+s+'" field must be a boolean value.');e=!!e}break;case Object:if(!i.isObject(e)){if(this.options.strictMode)return void this._error('The "'+s+'" field must be an object.');e={}}break;case t:i.hasOwnProperty(r,"enum")&&!r.enum.includes(e)&&this._error('The "'+s+'" field has an invalid value.');break;default:if(i.isArray(r.type)){if(!i.isArray(e)){if(this.options.strictMode)return void this._error('The "'+s+'" field must be an array.');e=[]}var h=[];for(let t in e){var m=await this._validate(e[t],r.type[0],s+"["+t+"]");void 0!==m?h.push(m):this.options.strictMode&&this._error('The "'+s+'" array has an invalid value at index "'+t+'".')}e=h,i.hasOwnProperty(r,"uniqueValues")&&r.uniqueValues&&(e=e.filter(((r,t)=>e.indexOf(r)===t))),i.hasOwnProperty(r,"maxEntries")&&e.length>r.maxEntries&&(this.options.strictMode?this._error('The "'+s+'" field must have at most "'+r.maxEntries+'" entries.'):e=e.slice(0,r.maxEntries)),i.hasOwnProperty(r,"minEntries")&&e.length<r.minEntries&&this._error('The "'+s+'" field must have at least "'+r.minEntries+'" entries.')}else{if(!i.isObject(e)){if(this.options.strictMode)return void this._error('The "'+s+'" field must be an object.');e={}}if(h={},this.options.throwUnkownFields)for(let t in e)i.hasOwnProperty(r,t)||this._error('Field "'+t+'" is not known.');for(let t in r){i.hasOwnProperty(r[t],"$or")||i.hasOwnProperty(r[t],"type")&&!i.isObject(r[t].type)||(e[t]=e[t]||{});var u=await this._validate(e[t],r[t],a?a+"."+t:t);void 0!==u&&(h[t]=u)}if(this.options.dismissEmptyObjects&&""!==a&&0==Object.keys(h).length)return;e=h}}if(i.hasOwnProperty(r,"validator"))try{e=(await Promise.all([r.validator(e)]))[0]}catch(e){return void this._error(String(e))}}else i.hasOwnProperty(r,"default")?e=r.default:i.hasOwnProperty(r,"required")&&r.required&&this._error('The "'+s+'" field is required.');return e}static get Builtins(){return{Url:{type:String,name:"URL",required:!0,lowercase:!1,trim:!0,match:/^(http|https):\/\/((?!-)[a-z0-9-]{1,63}(?<!-)\.)+[A-Za-z]{2,}(\/.*|$)/i},DomainName:{type:String,name:"Domain name",required:!0,lowercase:!0,trim:!0,match:/^((?!-)[a-z0-9-]{1,63}(?<!-)\.)+[a-z]{2,}$/},Email:{type:String,name:"Email address",required:!0,lowercase:!0,trim:!0,match:/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/},YoutubeVideo:{type:String,name:"Youtube Video Url",required:!0,lowercase:!1,trim:!0,match:/^(https?:\/\/)((?:www|m)\.)?((?:youtube(-nocookie)?\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$/i},VimeoVideo:{type:String,name:"Vimeo Video Url",required:!0,lowercase:!1,trim:!0,match:/^(http|https)?:\/\/(www\.|player\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|video\/|)(\d+)(?:|\/\?)/}}}static get Types(){return{String,Number,Boolean,Array,Object,Mixed:t}}static hasOwnProperty(e,r){return Object.prototype.hasOwnProperty.call(e,r)}static isObject(e){return e===Object(e)&&"object"==typeof e&&!i.isArray(e)}static isArray(e){return Array.isArray(e)}static isString(e){return"string"==typeof e}static isNumber(e){return"number"==typeof e&&!isNaN(e)}static isBoolean(e){return"boolean"==typeof e}static async validate(e,r,t){var a=new i(r,t);return await a.validate(e)}}module.exports.ElValidator=r; | ||
var e={d:(r,t)=>{for(var i in t)e.o(t,i)&&!e.o(r,i)&&Object.defineProperty(r,i,{enumerable:!0,get:t[i]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{Mixed:()=>t,default:()=>i});const t=Symbol("Mixed");class i{constructor(e={},r={}){this.schema=this._checkSchema(e),this.options={strictMode:!0,throwUnkownFields:!1,accumulateErrors:!1,dismissEmptyObjects:!0,...r},this.errors=[]}_checkSchema(e,r="Schema"){if(!i.isObject(e))throw new Error("The schema must be an object.");if(i.hasOwnProperty(e,"$or")){if(!i.isArray(e.$or))throw new Error(r+".$or must be an array.");e.$or=e.$or.map(((e,t)=>this._checkSchema({v:e},r+".$or["+t+"]").v))}else{if(!i.hasOwnProperty(e,"type")||i.isObject(e.type)){for(let t in e){let a=r+"."+t;if(i.isArray(e[t]))e[t]={type:e[t]};else if(!i.isObject(e[t]))throw new Error(a+" must be an object.");e[t]=this._checkSchema(e[t],a)}return e}if(i.isArray(e.type)){if(1!=e.type.length)throw new Error(r+" must have a single item.");e.type=[this._checkSchema({v:e.type[0]},r).v],i.hasOwnProperty(e,"minEntries")&&(e.minEntries=parseInt(e.minEntries)||0),i.hasOwnProperty(e,"maxEntries")&&(e.maxEntries=parseInt(e.maxEntries)||0),i.hasOwnProperty(e,"uniqueValues")&&(e.uniqueValues=!!e.uniqueValues),i.hasOwnProperty(e.type[0],"required")&&(e.required=!!e.type[0].required),e.minEntries&&e.minEntries>0&&(e.required=!0)}else if(e.type===String){if(i.hasOwnProperty(e,"maxLength")&&(e.maxLength=parseInt(e.maxLength)||0),i.hasOwnProperty(e,"minLength")&&(e.minLength=parseInt(e.minLength)||0),i.hasOwnProperty(e,"lowercase")&&(e.lowercase=!!e.lowercase),i.hasOwnProperty(e,"uppercase")&&(e.uppercase=!!e.uppercase),i.hasOwnProperty(e,"trim")&&(e.trim=!!e.trim),i.hasOwnProperty(e,"enum")){if(!i.isArray(e.enum))throw new Error(r+" must have an array value for its enum field.");e.enum=e.enum.map((e=>String(e)))}if(i.hasOwnProperty(e,"match")){if(!(e.match instanceof RegExp))throw new Error(r+' has an invalid RegExp for its "match" field.');e.match=e.match}}else if(e.type===Number){if(i.hasOwnProperty(e,"min")&&(e.min=parseInt(e.min)||0),i.hasOwnProperty(e,"max")&&(e.max=parseInt(e.max)||0),i.hasOwnProperty(e,"integer")&&(e.integer=!!e.integer),i.hasOwnProperty(e,"enum")){if(!i.isArray(e.enum))throw new Error(r+" must have an array value for its enum field.");e.enum=e.enum.map((e=>{if("number"!=typeof e)throw new Error(r+" enum values need to be numbers.");return parseInt(e)}))}}else if(e.type===Boolean);else if(e.type===Object);else{if(e.type!==t)throw new Error(r+' has an invalid value for the "type" field.');if(i.hasOwnProperty(e,"enum")){if(!i.isArray(e.enum))throw new Error(r+" must have an array value for its enum field.");e.enum=e.enum}}}if(i.hasOwnProperty(e,"default")&&(e.default=e.default),i.hasOwnProperty(e,"required")&&(e.required=!!e.required),i.hasOwnProperty(e,"name")&&(e.name=String(e.name)),i.hasOwnProperty(e,"validator")){if("function"!=typeof e.validator)throw new Error(r+' must have a function for the "validator" field.');e.validator=e.validator}return e}async validate(e){this.errors=[];var r=await this._validate(e,this.schema,"");if(this.errors.length>0)throw new Error(this.errors.join("\n"));return r}_error(e){if(!this.options.accumulateErrors)throw new Error(e);this.errors.push(e)}async _validate(e,r,a=""){var s=r.name||a||"Input";if(void 0!==e){if(i.hasOwnProperty(r,"$or")){var n=structuredClone(e),o=(e=void 0,this.errors);let t=[];for(let i in r.$or){this.errors=[],e=void 0;try{if(e=await this._validate(n,r.$or[i],s+".$or["+i+"]"),0==this.errors.length&&void 0!==e)break;t.push(...this.errors),e=void 0}catch(r){e=void 0}}return this.errors=o,void 0===e&&(i.hasOwnProperty(r,"default")?e=r.default:i.hasOwnProperty(r,"required")&&r.required&&this._error('The "'+s+'" field matches none of the possible formats.')),e}switch(r.type){case String:if(!i.isString(e)){if(this.options.strictMode)return void this._error('The "'+s+'" field must be a text value.');e=i.hasOwnProperty(r,"default")&&"number"!=typeof e?r.default:String(e)}r.uppercase&&(e=e.toUpperCase()),r.lowercase&&(e=e.toLowerCase()),r.trim&&(e=e.trim()),i.hasOwnProperty(r,"maxLength")&&e.length>r.maxLength&&(this.options.strictMode?this._error('The "'+s+'" field must be at most '+r.maxLength+" characters long."):e=e.subString(0,r.maxLength)),i.hasOwnProperty(r,"minLength")&&e.length<r.minLength&&this._error('The "'+s+'" field must be at least '+r.minLength+" characters long."),i.hasOwnProperty(r,"enum")&&!r.enum.includes(e)&&this._error('The "'+s+'" field has an invalid value.'),i.hasOwnProperty(r,"match")&&!e.match(r.match)&&this._error('The "'+s+"\" field doesn't match the required format.");break;case Number:if(!i.isNumber(e)){if(this.options.strictMode||!i.hasOwnProperty(r,"default"))return void this._error('The "'+s+'" field must be a number.');e=r.default}i.hasOwnProperty(r,"integer")&&r.integer&&Math.round(e)!=e&&(this.options.strictMode?this._error('The "'+s+'" field must be an integer.'):e=Math.round(e)),i.hasOwnProperty(r,"max")&&e>r.max&&(this.options.strictMode?this._error('The "'+s+'" field must be smaller than "'+r.max+'".'):e=r.max),i.hasOwnProperty(r,"min")&&e<r.min&&(this.options.strictMode?this._error('The "'+s+'" field must be greater than "'+r.min+'".'):e=r.min),i.hasOwnProperty(r,"enum")&&!r.enum.includes(e)&&this._error('The "'+s+'" field has an invalid value.');break;case Boolean:if(!i.isBoolean(e)){if(this.options.strictMode)return void this._error('The "'+s+'" field must be a boolean value.');e=!!e}break;case Object:if(!i.isObject(e)){if(this.options.strictMode)return void this._error('The "'+s+'" field must be an object.');e={}}break;case t:i.hasOwnProperty(r,"enum")&&!r.enum.includes(e)&&this._error('The "'+s+'" field has an invalid value.');break;default:if(i.isArray(r.type)){if(!i.isArray(e)){if(this.options.strictMode)return void this._error('The "'+s+'" field must be an array.');e=[]}var h=[];for(let t in e){var m=await this._validate(e[t],r.type[0],s+"["+t+"]");void 0!==m?h.push(m):this.options.strictMode&&this._error('The "'+s+'" array has an invalid value at index "'+t+'".')}e=h,i.hasOwnProperty(r,"uniqueValues")&&r.uniqueValues&&(e=e.filter(((r,t)=>e.indexOf(r)===t))),i.hasOwnProperty(r,"maxEntries")&&e.length>r.maxEntries&&(this.options.strictMode?this._error('The "'+s+'" field must have at most "'+r.maxEntries+'" entries.'):e=e.slice(0,r.maxEntries)),i.hasOwnProperty(r,"minEntries")&&e.length<r.minEntries&&this._error('The "'+s+'" field must have at least "'+r.minEntries+'" entries.')}else{if(!i.isObject(e)){if(this.options.strictMode)return void this._error('The "'+s+'" field must be an object.');e={}}if(h={},this.options.throwUnkownFields)for(let t in e)i.hasOwnProperty(r,t)||this._error('Field "'+t+'" is not known.');for(let t in r){i.hasOwnProperty(r[t],"$or")||i.hasOwnProperty(r[t],"type")&&!i.isObject(r[t].type)||(e[t]=e[t]||{});var u=await this._validate(e[t],r[t],a?a+"."+t:t);void 0!==u&&(h[t]=u)}if(this.options.dismissEmptyObjects&&""!==a&&0==Object.keys(h).length)return;e=h}}if(i.hasOwnProperty(r,"validator"))try{e=(await Promise.all([r.validator(e)]))[0]}catch(e){return void this._error(String(e))}}else i.hasOwnProperty(r,"default")?e=r.default:i.hasOwnProperty(r,"required")&&r.required&&this._error('The "'+s+'" field is required.');return e}static get Builtins(){return{Url:{type:String,name:"URL",required:!0,lowercase:!1,trim:!0,match:/^(http|https):\/\/([a-z0-9-]{1,63}\.)+[A-Za-z]{2,}(\/.*|$)/i},DomainName:{type:String,name:"Domain name",required:!0,lowercase:!0,trim:!0,match:/^([a-z0-9-]{1,63}\.)+[a-z]{2,}$/},Email:{type:String,name:"Email address",required:!0,lowercase:!0,trim:!0,match:/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/},YoutubeVideo:{type:String,name:"Youtube Video Url",required:!0,lowercase:!1,trim:!0,match:/^(https?:\/\/)((?:www|m)\.)?((?:youtube(-nocookie)?\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$/i},VimeoVideo:{type:String,name:"Vimeo Video Url",required:!0,lowercase:!1,trim:!0,match:/^(http|https)?:\/\/(www\.|player\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|video\/|)(\d+)(?:|\/\?)/}}}static get Types(){return{String,Number,Boolean,Array,Object,Mixed:t}}static hasOwnProperty(e,r){return Object.prototype.hasOwnProperty.call(e,r)}static isObject(e){return e===Object(e)&&"object"==typeof e&&!i.isArray(e)}static isArray(e){return Array.isArray(e)}static isString(e){return"string"==typeof e}static isNumber(e){return"number"==typeof e&&!isNaN(e)}static isBoolean(e){return"boolean"==typeof e}static async validate(e,r,t){var a=new i(r,t);return await a.validate(e)}}module.exports.ElValidator=r; |
@@ -355,4 +355,4 @@ export const Mixed = Symbol('Mixed'); | ||
return { | ||
Url : { type:String, name: 'URL', required: true, lowercase:false, trim:true, match:/^(http|https):\/\/((?!-)[a-z0-9-]{1,63}(?<!-)\.)+[A-Za-z]{2,}(\/.*|$)/i}, | ||
DomainName : { type:String, name: 'Domain name', required: true, lowercase:true, trim:true, match:/^((?!-)[a-z0-9-]{1,63}(?<!-)\.)+[a-z]{2,}$/}, | ||
Url : { type:String, name: 'URL', required: true, lowercase:false, trim:true, match:/^(http|https):\/\/([a-z0-9-]{1,63}\.)+[A-Za-z]{2,}(\/.*|$)/i}, | ||
DomainName : { type:String, name: 'Domain name', required: true, lowercase:true, trim:true, match:/^([a-z0-9-]{1,63}\.)+[a-z]{2,}$/}, | ||
Email : { type:String, name: 'Email address', required: true, lowercase:true, trim:true, match:/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/}, | ||
@@ -359,0 +359,0 @@ YoutubeVideo : { type:String, name: 'Youtube Video Url', required: true, lowercase:false, trim:true, match:/^(https?:\/\/)((?:www|m)\.)?((?:youtube(-nocookie)?\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$/i}, |
{ | ||
"name": "elvalidator", | ||
"version": "1.7.4", | ||
"version": "1.7.6", | ||
"description": "Validate and Sanitize JSON objects.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
44055