Comparing version 0.2.1 to 0.2.2
@@ -24,12 +24,12 @@ export declare class Validator { | ||
isTime(value: any): boolean; | ||
isBooleanFormat(value: string): boolean; | ||
isNumberFormat(value: string): boolean; | ||
isIntegerFormat(value: string): boolean; | ||
isDecimalFormat(value: string): boolean; | ||
isAlphanumeric(value: string): boolean; | ||
isDateFormat(value: string): boolean; | ||
isDateTimeFormat(value: string): boolean; | ||
isTimeFormat(value: string): boolean; | ||
isBooleanFormat(value: any): boolean; | ||
isNumberFormat(value: any): boolean; | ||
isIntegerFormat(value: any): boolean; | ||
isDecimalFormat(value: any): boolean; | ||
isAlphanumeric(value: any): boolean; | ||
isDateFormat(value: any): boolean; | ||
isDateTimeFormat(value: any): boolean; | ||
isTimeFormat(value: any): boolean; | ||
between(value: any, from: any, to: any): boolean; | ||
includes(list: any[] | string, value: any): boolean; | ||
} |
@@ -49,5 +49,11 @@ "use strict"; | ||
isString(value) { | ||
if (value === null || value === undefined) { | ||
return false; | ||
} | ||
return typeof value === 'string'; | ||
} | ||
isDate(value) { | ||
if (value === null || value === undefined) { | ||
return false; | ||
} | ||
if (typeof value === 'string') { | ||
@@ -61,2 +67,5 @@ return this.isDateFormat(value); | ||
isDateTime(value) { | ||
if (value === null || value === undefined) { | ||
return false; | ||
} | ||
if (typeof value === 'string') { | ||
@@ -70,5 +79,11 @@ return this.isDateTimeFormat(value); | ||
isArray(value) { | ||
if (value === null || value === undefined) { | ||
return false; | ||
} | ||
return Array.isArray(value); | ||
} | ||
isTime(value) { | ||
if (value === null || value === undefined) { | ||
return false; | ||
} | ||
if (typeof value === 'string') { | ||
@@ -82,3 +97,6 @@ return this.isTimeFormat(value); | ||
isBooleanFormat(value) { | ||
return ['true', 'false'].includes(value); | ||
if (value === null || value === undefined) { | ||
return false; | ||
} | ||
return ['true', 'false'].includes(value.toString()); | ||
} | ||
@@ -89,11 +107,23 @@ isNumberFormat(value) { | ||
isIntegerFormat(value) { | ||
if (value === null || value === undefined) { | ||
return false; | ||
} | ||
return this.reInt.test(value); | ||
} | ||
isDecimalFormat(value) { | ||
if (value === null || value === undefined) { | ||
return false; | ||
} | ||
return this.reDecimal.test(value); | ||
} | ||
isAlphanumeric(value) { | ||
if (value === null || value === undefined) { | ||
return false; | ||
} | ||
return this.reAlphanumeric.test(value); | ||
} | ||
isDateFormat(value) { | ||
if (value === null || value === undefined) { | ||
return false; | ||
} | ||
return this.reDate.test(value); | ||
@@ -105,5 +135,11 @@ } | ||
isTimeFormat(value) { | ||
if (value === null || value === undefined) { | ||
return false; | ||
} | ||
return this.reTime.test(value); | ||
} | ||
between(value, from, to) { | ||
if (value === null || value === undefined || from === null || from === undefined || to === null || to === undefined) { | ||
return false; | ||
} | ||
return value >= from && value < to; | ||
@@ -110,0 +146,0 @@ } |
{ | ||
"name": "h3lp", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Helper for nodeJs", | ||
@@ -5,0 +5,0 @@ "author": "Flavio Lionel Rita <flaviolrita@hotmail.com>", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
114005
1496