mastercheck
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -41,5 +41,5 @@ /** | ||
Number: function(option) { | ||
option = option || {}; | ||
this.option = option || {}; | ||
this.check = function(data) { | ||
if (!option.required && data === undefined) { | ||
if (!this.option.required && data === undefined) { | ||
return; | ||
@@ -53,7 +53,7 @@ } | ||
} | ||
if (option.hasOwnProperty('min') && option.min > data) { | ||
return data + ' should be above ' + option.min; | ||
if (this.option.hasOwnProperty('min') && this.option.min > data) { | ||
return data + ' should be above ' + this.option.min; | ||
} | ||
if (option.hasOwnProperty('max') && option.max < data) { | ||
return data + ' should be below ' + option.max; | ||
if (this.option.hasOwnProperty('max') && this.option.max < data) { | ||
return data + ' should be below ' + this.option.max; | ||
} | ||
@@ -75,5 +75,5 @@ }; | ||
String: function(option) { | ||
option = option || {}; | ||
this.option = option || {}; | ||
this.check = function(data) { | ||
if (!option.required && data === undefined) { | ||
if (!this.option.required && data === undefined) { | ||
return; | ||
@@ -87,13 +87,13 @@ } | ||
} | ||
if (option.hasOwnProperty('minLength') && option.minLength > data.length) { | ||
return data + ' length should be above ' + option.minLength; | ||
if (this.option.hasOwnProperty('minLength') && this.option.minLength > data.length) { | ||
return data + ' length should be above ' + this.option.minLength; | ||
} | ||
if (option.hasOwnProperty('maxLength') && option.maxLength < data.length) { | ||
return data + ' length should be below ' + option.maxLength; | ||
if (this.option.hasOwnProperty('maxLength') && this.option.maxLength < data.length) { | ||
return data + ' length should be below ' + this.option.maxLength; | ||
} | ||
if (option.hasOwnProperty('match') && !data.match(option.match)) { | ||
return data + ' should match ' + option.match; | ||
if (this.option.hasOwnProperty('match') && !data.match(this.option.match)) { | ||
return data + ' should match ' + this.option.match; | ||
} | ||
if (option.hasOwnProperty('select') && !~option.select.indexOf(data)) { | ||
return data + ' should match ' + option.select.join(' or '); | ||
if (this.option.hasOwnProperty('select') && !~this.option.select.indexOf(data)) { | ||
return data + ' should match ' + this.option.select.join(' or '); | ||
} | ||
@@ -112,5 +112,5 @@ }; | ||
Boolean: function(option) { | ||
option = option || {}; | ||
this.option = option || {}; | ||
this.check = function(data) { | ||
if (!option.required && data === undefined) { | ||
if (!this.option.required && data === undefined) { | ||
return; | ||
@@ -137,5 +137,5 @@ } | ||
Object: function(option, format) { | ||
option = option || {}; | ||
this.option = option || {}; | ||
this.check = function(data) { | ||
if (!option.required && data === undefined) { | ||
if (!this.option.required && data === undefined) { | ||
return; | ||
@@ -165,5 +165,5 @@ } | ||
Array: function(option, format) { | ||
option = option || {}; | ||
this.option = option || {}; | ||
this.check = function(data) { | ||
if (!option.required && data === undefined) { | ||
if (!this.option.required && data === undefined) { | ||
return; | ||
@@ -177,7 +177,7 @@ } | ||
} | ||
if (option.hasOwnProperty('minLength') && option.minLength > data.length) { | ||
return data + ' length should be above ' + option.minLength; | ||
if (this.option.hasOwnProperty('minLength') && this.option.minLength > data.length) { | ||
return data + ' length should be above ' + this.option.minLength; | ||
} | ||
if (option.hasOwnProperty('maxLength') && option.maxLength < data.length) { | ||
return data + ' length should be below ' + option.maxLength; | ||
if (this.option.hasOwnProperty('maxLength') && this.option.maxLength < data.length) { | ||
return data + ' length should be below ' + this.option.maxLength; | ||
} | ||
@@ -199,12 +199,12 @@ }; | ||
Map: function(option, format) { | ||
option = option || {}; | ||
this.option = option || {}; | ||
this.check = function(data) { | ||
if (option.hasOwnProperty('maxLength') && option.maxLength < data.length) { | ||
return data + ' length should be above ' + option.maxLength; | ||
if (this.option.hasOwnProperty('maxLength') && this.option.maxLength < data.length) { | ||
return data + ' length should be above ' + this.option.maxLength; | ||
} | ||
if (option.hasOwnProperty('match') && !data.match(option.match)) { | ||
return data + ' should match ' + option.match; | ||
if (this.option.hasOwnProperty('match') && !data.match(this.option.match)) { | ||
return data + ' should match ' + this.option.match; | ||
} | ||
if (option.hasOwnProperty('select') && !~option.select.indexOf(data)) { | ||
return data + ' should match ' + option.select; | ||
if (this.option.hasOwnProperty('select') && !~this.option.select.indexOf(data)) { | ||
return data + ' should match ' + this.option.select; | ||
} | ||
@@ -211,0 +211,0 @@ }; |
{ | ||
"name": "mastercheck", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "mastercheck", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
33370