@briza/wegood
Advanced tools
Comparing version 1.0.7 to 1.0.8
# wegood changelog | ||
## 1.0.8 | ||
* Update: Include/Exclude rule supports boolean values. | ||
## 1.0.7 | ||
@@ -4,0 +8,0 @@ |
@@ -155,2 +155,11 @@ function _typeof(obj) { | ||
/** | ||
* Is boolean type predicate. | ||
* @param value | ||
* @return | ||
*/ | ||
function isBoolean(value) { | ||
return value === false || value === true; | ||
} | ||
/** | ||
* Is function type predicate. | ||
@@ -552,3 +561,3 @@ * @param value | ||
return function (value) { | ||
if (isNullOrUndefined(value) || isString(value) === false && isNumber(value) === false) { | ||
if (isNullOrUndefined(value) || !isBoolean(value) && !isString(value) && !isNumber(value)) { | ||
return errorMsg; | ||
@@ -576,7 +585,7 @@ } | ||
if (inclusions.length === 0) { | ||
console.warn("the include validation rule without any inclusions\n has no validation effect, it will be always validated as false."); | ||
console.warn("the include validation rule without any inclusions'\n has no validation effect, it will be always validated as false."); | ||
} | ||
return function (value) { | ||
if (isNullOrUndefined(value) || isString(value) === false && isNumber(value) === false) { | ||
if (isNullOrUndefined(value) || !isBoolean(value) && !isString(value) && !isNumber(value)) { | ||
return errorMsg; | ||
@@ -583,0 +592,0 @@ } |
@@ -159,2 +159,11 @@ 'use strict'; | ||
/** | ||
* Is boolean type predicate. | ||
* @param value | ||
* @return | ||
*/ | ||
function isBoolean(value) { | ||
return value === false || value === true; | ||
} | ||
/** | ||
* Is function type predicate. | ||
@@ -556,3 +565,3 @@ * @param value | ||
return function (value) { | ||
if (isNullOrUndefined(value) || isString(value) === false && isNumber(value) === false) { | ||
if (isNullOrUndefined(value) || !isBoolean(value) && !isString(value) && !isNumber(value)) { | ||
return errorMsg; | ||
@@ -580,7 +589,7 @@ } | ||
if (inclusions.length === 0) { | ||
console.warn("the include validation rule without any inclusions\n has no validation effect, it will be always validated as false."); | ||
console.warn("the include validation rule without any inclusions'\n has no validation effect, it will be always validated as false."); | ||
} | ||
return function (value) { | ||
if (isNullOrUndefined(value) || isString(value) === false && isNumber(value) === false) { | ||
if (isNullOrUndefined(value) || !isBoolean(value) && !isString(value) && !isNumber(value)) { | ||
return errorMsg; | ||
@@ -587,0 +596,0 @@ } |
{ | ||
"name": "@briza/wegood", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Tiny validation library, so wegood with data.", | ||
@@ -5,0 +5,0 @@ "main": "lib/wegood.js", |
@@ -20,2 +20,8 @@ /** | ||
/** | ||
* Is boolean type predicate. | ||
* @param value | ||
* @return | ||
*/ | ||
export declare function isBoolean(value: any): value is boolean; | ||
/** | ||
* Is function type predicate. | ||
@@ -22,0 +28,0 @@ * @param value |
@@ -9,3 +9,3 @@ import { ValidationRule } from '.'; | ||
*/ | ||
declare function exclude(errorMsg: string, exclusions: (string | number)[]): ValidationRule; | ||
declare function exclude(errorMsg: string, exclusions: (string | number | boolean)[]): ValidationRule; | ||
export default exclude; |
@@ -9,3 +9,3 @@ import { ValidationRule } from '.'; | ||
*/ | ||
declare function include(errorMsg: string, inclusions: (string | number)[]): ValidationRule; | ||
declare function include(errorMsg: string, inclusions: (string | number | boolean)[]): ValidationRule; | ||
export default include; |
75240
1766