diff --git a/.eslintignore b/.eslintignore index 82cc41b..9b1d071 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,4 @@ /* + !/src +!/test diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 3c3050e..6a788e4 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -1,19 +1,15 @@ # 使用 airbnb 规则 -extends: 'eslint-config-airbnb-es5' +extends: + - "eslint:recommended" + - 'eslint-config-airbnb-es5' # 全局环境变量 env: - # es6 es6: false - # browser browser: true - # node node: true - # commonjs commonjs: true - # amd amd: true - # mocha mocha: true # js 语言选项 @@ -27,28 +23,42 @@ parserOptions: # 2: error 开启规则, 使用错误级别的错误, 会导致程序退出 rules: # 强制一行的最大长度 - # max-len: - # - 2 - # - 120 + max-len: [error, 120, { + ignoreUrls: true, # 忽略含有链接的行 + ignoreComments: true, # 忽略所有拖尾注释和行内注释 + ignoreTrailingComments: true, # 忽略拖尾注释 + ignoreStrings: true, # 忽略含有双引号或单引号字符串的行 + ignoreRegExpLiterals: true, # 忽略包含正则表达式的行 + ignoreTemplateLiterals: true, # 忽略包含模板字面量的行 + }] + + # 强制使用一致的缩进 + indent: [error, 2, { + SwitchCase: 1 # 强制 switch 语句中的 case 子句的缩进级别 => 0: 不会缩进, 1: case 相对于 switch 缩进 2 格 (如果缩进设置为 2 个空格) + }] + + # 强制在 switch 的冒号左右有空格 + switch-colon-spacing: [error, { + after: false, # 禁止冒号之后有空格 + before: false # 禁止冒号之前有空格 + }] + + # 强制使用一致的反勾号、双引号或单引号 + quotes: [error, single, { + allowTemplateLiterals: true, # 允许字符串使用反勾号 + }] # 禁止自身比较 - no-self-compare: - - 0 + no-self-compare: [0] # 禁用不必要的转义字符 - no-useless-escape: - - 0 + no-useless-escape: [0] - # 要求或禁止使用命名的 function 表达式 - func-names: - - 0 + # 禁止将 undefined 作为标识符 + no-undefined: [0] - # 强制使用一致的反勾号、双引号或单引号 - quotes: - - 2 - - single - - allowTemplateLiterals: true - -# globals: -# describe: true -# it: true + # 禁止数字字面量中使用前导和末尾小数点 + no-floating-decimal: [0] + + # 要求或禁止使用命名的 function 表达式 + func-names: [0] diff --git a/.gitignore b/.gitignore index b5c4067..1bac64f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea +.vscode .DS_Store package-lock.json diff --git a/.travis.yml b/.travis.yml index 84b69c1..48ee223 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ node_js: - 5 script: - - npm run jxmCoverage + - npm run test:coverage after_script: - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js diff --git a/README.zh-CN.md b/README.zh-CN.md index a0feebf..2bf4581 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -11,7 +11,7 @@ validator > [中文](https://github.com/sTdobTs/validator/blob/master/README.zh-CN.md) | [English](https://github.com/sTdobTs/validator) -基于 ECMAScript 5.1 实现的验证工具包,提供了丰富的校验方法,在 Node.js 和现代浏览器中可以使用。 +基于 ECMAScript 5.1 实现的验证工具包,提供了丰富的校验方法,在 Node.js 和现代浏览器中都可以使用。 ## 安装 diff --git a/docs/en-US/APIs/isArray.md b/docs/en-US/APIs/isArray.md index 28b2cc5..6ae90fd 100644 --- a/docs/en-US/APIs/isArray.md +++ b/docs/en-US/APIs/isArray.md @@ -18,11 +18,10 @@ ```javascript jxmValidator.isArray([]); // => true jxmValidator.isArray({}); // => false -jxmValidator.isArray(parseInt); // => false jxmValidator.isArray(new Date()); // => false jxmValidator.isArray(null); // => false + jxmValidator.isArray(Object({})); // => false jxmValidator.isArray(Object([])); // => true -jxmValidator.isArray(new Object([])); // => true ``` diff --git a/docs/en-US/APIs/isBoolean.md b/docs/en-US/APIs/isBoolean.md index 88f36fd..c97ca3f 100644 --- a/docs/en-US/APIs/isBoolean.md +++ b/docs/en-US/APIs/isBoolean.md @@ -16,7 +16,6 @@ #### 示例: ```javascript -// boolean jxmValidator.isBoolean(true); // => true jxmValidator.isBoolean(false); // => true @@ -24,9 +23,5 @@ jxmValidator.isBoolean(0); // => false jxmValidator.isBoolean(''); // => false jxmValidator.isBoolean(null); // => false jxmValidator.isBoolean(undefined); // => false - -// boolean 包装对象 -jxmValidator.isBoolean(Boolean(true)); // => true -jxmValidator.isBoolean(new Boolean(true)); // => true jxmValidator.isBoolean({}); // => false ``` diff --git a/docs/en-US/APIs/isEmptyString.md b/docs/en-US/APIs/isEmptyString.md index 68731e0..cac5a47 100644 --- a/docs/en-US/APIs/isEmptyString.md +++ b/docs/en-US/APIs/isEmptyString.md @@ -40,13 +40,11 @@ jxmValidator.isEmptyString('3'); // => false jxmValidator.isEmptyString(0); // => false jxmValidator.isEmptyString(''); // => true -jxmValidator.isEmptyString('', {isStrict: false})); // => true - jxmValidator.isEmptyString(' '); // => true +jxmValidator.isEmptyString('', {isStrict: false})); // => true jxmValidator.isEmptyString(' ', {isStrict: false}); // => false jxmValidator.isEmptyString(null); // => false jxmValidator.isEmptyString(undefined); // => false - jxmValidator.isEmptyString(NaN); // => false ``` diff --git a/docs/en-US/APIs/isInfinity.md b/docs/en-US/APIs/isInfinity.md index 33412c2..4a37ef2 100644 --- a/docs/en-US/APIs/isInfinity.md +++ b/docs/en-US/APIs/isInfinity.md @@ -23,6 +23,7 @@ jxmValidator.isInfinity(NaN); // => false jxmValidator.isInfinity(null); // => false jxmValidator.isInfinity(undefined); // => false +jxmValidator.isInfinity(0); // => false jxmValidator.isInfinity(3); // => false jxmValidator.isInfinity(''); // => false ``` diff --git a/docs/en-US/APIs/isInteger.md b/docs/en-US/APIs/isInteger.md index 60d05eb..2249423 100644 --- a/docs/en-US/APIs/isInteger.md +++ b/docs/en-US/APIs/isInteger.md @@ -36,10 +36,18 @@ #### 示例: ```javascript +jxmValidator.isInteger(.3); // => false jxmValidator.isInteger(3); // => true +jxmValidator.isInteger(3.3); // => false +jxmValidator.isInteger('.3'); // => false jxmValidator.isInteger('3'); // => true +jxmValidator.isInteger('3.3'); // => false +jxmValidator.isInteger(.3, {isStrict: true}); // => false jxmValidator.isInteger(3, {isStrict: true}); // => true +jxmValidator.isInteger(3.3, {isStrict: true}); // => false +jxmValidator.isInteger('.3', {isStrict: true}); // => false jxmValidator.isInteger('3', {isStrict: true}); // => false +jxmValidator.isInteger('3.3', {isStrict: true}); // => false jxmValidator.isInteger(0); // => true jxmValidator.isInteger('0'); // => true @@ -51,16 +59,6 @@ jxmValidator.isInteger('-3'); // => true jxmValidator.isInteger(-3, {isStrict: true}); // => true jxmValidator.isInteger('-3', {isStrict: true}); // => false -jxmValidator.isInteger(3.3); // => false -jxmValidator.isInteger('3.3'); // => false -jxmValidator.isInteger(3.3, {isStrict: true}); // => false -jxmValidator.isInteger('3.3', {isStrict: true}); // => false - -jxmValidator.isInteger(-3.3); // => false -jxmValidator.isInteger('-3.3'); // => false -jxmValidator.isInteger(-3.3, {isStrict: true}); // => false -jxmValidator.isInteger('-3.3', {isStrict: true}); // => false - jxmValidator.isInteger(''); // => false jxmValidator.isInteger(' '); // => false jxmValidator.isInteger(null); // => false diff --git a/docs/en-US/APIs/isNegativeInteger.md b/docs/en-US/APIs/isNegativeInteger.md index 95ee1d8..0023fc8 100644 --- a/docs/en-US/APIs/isNegativeInteger.md +++ b/docs/en-US/APIs/isNegativeInteger.md @@ -36,30 +36,28 @@ #### 示例: ```javascript -jxmValidator.isNegativeInteger(3); // => false -jxmValidator.isNegativeInteger('3'); // => false -jxmValidator.isNegativeInteger(3, {isStrict: true}); // => false -jxmValidator.isNegativeInteger('3', {isStrict: true}); // => false - -jxmValidator.isNegativeInteger(0); // => false -jxmValidator.isNegativeInteger('0'); // => false -jxmValidator.isNegativeInteger(0, {isStrict: true}); // => false -jxmValidator.isNegativeInteger('0', {isStrict: true}); // => false - +jxmValidator.isNegativeInteger(-.3); // => false jxmValidator.isNegativeInteger(-3); // => true +jxmValidator.isNegativeInteger(-3.3); // => false +jxmValidator.isNegativeInteger('-.3'); // => false jxmValidator.isNegativeInteger('-3'); // => true +jxmValidator.isNegativeInteger('-3.3'); // => false +jxmValidator.isNegativeInteger(-.3, {isStrict: true}); // => false jxmValidator.isNegativeInteger(-3, {isStrict: true}); // => true +jxmValidator.isNegativeInteger(-3.3, {isStrict: true}); // => false +jxmValidator.isNegativeInteger('-.3', {isStrict: true}); // => false jxmValidator.isNegativeInteger('-3', {isStrict: true}); // => false +jxmValidator.isNegativeInteger('-3.3', {isStrict: true}); // => false -jxmValidator.isNegativeInteger(3.3); // => false -jxmValidator.isNegativeInteger('3.3'); // => false -jxmValidator.isNegativeInteger(3.3, {isStrict: true}); // => false -jxmValidator.isNegativeInteger('3.3', {isStrict: true}); // => false +jxmValidator.isNegativeInteger(0); // => false +jxmValidator.isNegativeInteger('0'); // => false +jxmValidator.isNegativeInteger(0, {isStrict: true}); // => false +jxmValidator.isNegativeInteger('0', {isStrict: true}); // => false -jxmValidator.isNegativeInteger(-3.3); // => false -jxmValidator.isNegativeInteger('-3.3'); // => false -jxmValidator.isNegativeInteger(-3.3, {isStrict: true}); // => false -jxmValidator.isNegativeInteger('-3.3', {isStrict: true}); // => false +jxmValidator.isNegativeInteger(3); // => false +jxmValidator.isNegativeInteger('3'); // => false +jxmValidator.isNegativeInteger(3, {isStrict: true}); // => false +jxmValidator.isNegativeInteger('3', {isStrict: true}); // => false jxmValidator.isNegativeInteger(''); // => false jxmValidator.isNegativeInteger(' '); // => false diff --git a/docs/en-US/APIs/isNegativeNumber.md b/docs/en-US/APIs/isNegativeNumber.md index 867576d..acba38f 100644 --- a/docs/en-US/APIs/isNegativeNumber.md +++ b/docs/en-US/APIs/isNegativeNumber.md @@ -36,10 +36,18 @@ #### 示例: ```javascript +jxmValidator.isNegativeNumber(-.3); // => true jxmValidator.isNegativeNumber(-3); // => true +jxmValidator.isNegativeNumber(-3.5); // => true +jxmValidator.isNegativeNumber('-.3'); // => true jxmValidator.isNegativeNumber('-3'); // => true +jxmValidator.isNegativeNumber('-3.5'); // => true +jxmValidator.isNegativeNumber(-.3, {isStrict: true}); // => true jxmValidator.isNegativeNumber(-3, {isStrict: true}); // => true +jxmValidator.isNegativeNumber(-3.5, {isStrict: true}); // => true +jxmValidator.isNegativeNumber('-.3', {isStrict: true}); // => false jxmValidator.isNegativeNumber('-3', {isStrict: true}); // => false +jxmValidator.isNegativeNumber('-3.5', {isStrict: true}); // => false jxmValidator.isNegativeNumber(0); // => false jxmValidator.isNegativeNumber('0'); // => false diff --git a/docs/en-US/APIs/isNumber.md b/docs/en-US/APIs/isNumber.md index 27da65c..0256224 100644 --- a/docs/en-US/APIs/isNumber.md +++ b/docs/en-US/APIs/isNumber.md @@ -13,12 +13,11 @@ 当参数 val 为 `number` 时,返回 `true`, 否则返回 `false` - * number 类型还包括: NaN, Infinity, -Infinity + * number 类型还包括: NaN, Infinity, -Infinity, ... #### 示例: ```javascript -// number jxmValidator.isNumber(3); // => true jxmValidator.isNumber('3'); // => false @@ -30,12 +29,5 @@ jxmValidator.isNumber(''); // => false jxmValidator.isNumber(true); // => false jxmValidator.isNumber(null); // => false jxmValidator.isNumber(undefined); // => false - -// number 包装对象 -jxmValidator.isNumber(Number(3)); // => true -jxmValidator.isNumber(new Number(3)); // => true - jxmValidator.isNumber({}); // => false -jxmValidator.isNumber(Object(3)); // => true -jxmValidator.isNumber(Object('3')); // => false ``` diff --git a/docs/en-US/APIs/isNumeric.md b/docs/en-US/APIs/isNumeric.md index d252f81..0b161f3 100644 --- a/docs/en-US/APIs/isNumeric.md +++ b/docs/en-US/APIs/isNumeric.md @@ -51,10 +51,7 @@ jxmValidator.isNumeric(' '); // => false jxmValidator.isNumeric(null); // => false jxmValidator.isNumeric(undefined); // => false -jxmValidator.isNumeric(Number(3)); // => true -jxmValidator.isNumeric(new Number(3)); // => true jxmValidator.isNumeric({}); // => false - jxmValidator.isNumeric(Object(3)); // => true jxmValidator.isNumeric(Object('3')); // => true jxmValidator.isNumeric(Object('3', {isStrict: true})); // => false diff --git a/docs/en-US/APIs/isObject.md b/docs/en-US/APIs/isObject.md index ffa0379..6b61c76 100644 --- a/docs/en-US/APIs/isObject.md +++ b/docs/en-US/APIs/isObject.md @@ -21,9 +21,8 @@ jxmValidator.isObject([]); // => false jxmValidator.isObject(parseInt); // => false jxmValidator.isObject(new Date()); // => false +jxmValidator.isObject(Object('3')); // => false jxmValidator.isObject(Object({})); // => true -jxmValidator.isObject(Object('3'); // => false -jxmValidator.isObject(new Object('3')); // => false jxmValidator.isObject(null); // => false jxmValidator.isObject(Object.create(null)); // => true diff --git a/docs/en-US/APIs/isPlainObject.md b/docs/en-US/APIs/isPlainObject.md index 0a9a692..0a2249c 100644 --- a/docs/en-US/APIs/isPlainObject.md +++ b/docs/en-US/APIs/isPlainObject.md @@ -21,9 +21,9 @@ jxmValidator.isPlainObject([]); // => false jxmValidator.isPlainObject(parseInt); // => false jxmValidator.isPlainObject(new Date()); // => false -jxmValidator.isPlainObject(Object({})); // => true jxmValidator.isPlainObject(Object('3'); // => false -jxmValidator.isPlainObject(new Object('3'); // => false +jxmValidator.isPlainObject(Object([])); // => false +jxmValidator.isPlainObject(Object({})); // => true jxmValidator.isPlainObject(null); // => false jxmValidator.isPlainObject(Object.create(null)); // => true diff --git a/docs/en-US/APIs/isPositiveInteger.md b/docs/en-US/APIs/isPositiveInteger.md index 9df6985..9b0582f 100644 --- a/docs/en-US/APIs/isPositiveInteger.md +++ b/docs/en-US/APIs/isPositiveInteger.md @@ -36,10 +36,18 @@ #### 示例: ```javascript +jxmValidator.isPositiveInteger(.3); // => false jxmValidator.isPositiveInteger(3); // => true +jxmValidator.isPositiveInteger(3.3); // => false +jxmValidator.isPositiveInteger('.3'); // => false jxmValidator.isPositiveInteger('3'); // => true +jxmValidator.isPositiveInteger('3.3'); // => false +jxmValidator.isPositiveInteger(.3, {isStrict: true}); // => false jxmValidator.isPositiveInteger(3, {isStrict: true}); // => true +jxmValidator.isPositiveInteger(3.3, {isStrict: true}); // => false +jxmValidator.isPositiveInteger('.3', {isStrict: true}); // => false jxmValidator.isPositiveInteger('3', {isStrict: true}); // => false +jxmValidator.isPositiveInteger('3.3', {isStrict: true}); // => false jxmValidator.isPositiveInteger(0); // => false jxmValidator.isPositiveInteger('0'); // => false @@ -51,16 +59,6 @@ jxmValidator.isPositiveInteger('-3'); // => false jxmValidator.isPositiveInteger(-3, {isStrict: true}); // => false jxmValidator.isPositiveInteger('-3', {isStrict: true}); // => false -jxmValidator.isPositiveInteger(3.3); // => false -jxmValidator.isPositiveInteger('3.3'); // => false -jxmValidator.isPositiveInteger(3.3, {isStrict: true}); // => false -jxmValidator.isPositiveInteger('3.3', {isStrict: true}); // => false - -jxmValidator.isPositiveInteger(-3.3); // => false -jxmValidator.isPositiveInteger('-3.3'); // => false -jxmValidator.isPositiveInteger(-3.3, {isStrict: true}); // => false -jxmValidator.isPositiveInteger('-3.3', {isStrict: true}); // => false - jxmValidator.isPositiveInteger(''); // => false jxmValidator.isPositiveInteger(' '); // => false jxmValidator.isPositiveInteger(null); // => false diff --git a/docs/en-US/APIs/isPositiveNumber.md b/docs/en-US/APIs/isPositiveNumber.md index a29a723..7c2cbe0 100644 --- a/docs/en-US/APIs/isPositiveNumber.md +++ b/docs/en-US/APIs/isPositiveNumber.md @@ -36,10 +36,18 @@ #### 示例: ```javascript +jxmValidator.isPositiveNumber(.3); // => true jxmValidator.isPositiveNumber(3); // => true +jxmValidator.isPositiveNumber(3.5); // => true +jxmValidator.isPositiveNumber('.3'); // => true jxmValidator.isPositiveNumber('3'); // => true +jxmValidator.isPositiveNumber('3.5'); // => true +jxmValidator.isPositiveNumber(.3, {isStrict: true}); // => true jxmValidator.isPositiveNumber(3, {isStrict: true}); // => true +jxmValidator.isPositiveNumber(3.5, {isStrict: true}); // => true +jxmValidator.isPositiveNumber('.3', {isStrict: true}); // => false jxmValidator.isPositiveNumber('3', {isStrict: true}); // => false +jxmValidator.isPositiveNumber('3.5', {isStrict: true}); // => false jxmValidator.isPositiveNumber(0); // => false jxmValidator.isPositiveNumber('0'); // => false @@ -49,7 +57,7 @@ jxmValidator.isPositiveNumber('0', {isStrict: true}); // => false jxmValidator.isPositiveNumber(-3); // => false jxmValidator.isPositiveNumber('-3'); // => false jxmValidator.isPositiveNumber(-3, {isStrict: true}); // => false -jxmValidator.isPositiveNumber('3', {isStrict: true}); // => false +jxmValidator.isPositiveNumber('-3', {isStrict: true}); // => false jxmValidator.isPositiveNumber(''); // => false jxmValidator.isPositiveNumber(' '); // => false diff --git a/docs/en-US/APIs/isRealNumber.md b/docs/en-US/APIs/isRealNumber.md index beb5fd7..167894f 100644 --- a/docs/en-US/APIs/isRealNumber.md +++ b/docs/en-US/APIs/isRealNumber.md @@ -51,9 +51,6 @@ jxmValidator.isRealNumber(' '); // => false jxmValidator.isRealNumber(null); // => false jxmValidator.isRealNumber(undefined); // => false -jxmValidator.isRealNumber(Number(3)); // => true -jxmValidator.isRealNumber(new Number(3)); // => true - jxmValidator.isRealNumber({}); // => false jxmValidator.isRealNumber(Object(3)); // => true jxmValidator.isRealNumber(Object('3')); // => true diff --git a/docs/en-US/APIs/isString.md b/docs/en-US/APIs/isString.md index f3a8674..0c927de 100644 --- a/docs/en-US/APIs/isString.md +++ b/docs/en-US/APIs/isString.md @@ -16,7 +16,6 @@ #### 示例: ```javascript -// string jxmValidator.isString(''); // => true jxmValidator.isString(' '); // => true @@ -27,11 +26,8 @@ jxmValidator.isString(true); // => false jxmValidator.isString(null); // => false jxmValidator.isString(undefined); // => false -// string 包装对象 -jxmValidator.isString(String(3)); // => true -jxmValidator.isString(new String(3)); // => true - jxmValidator.isString({}); // => false -jxmValidator.isString(Object('3')); // => true + jxmValidator.isString(Object(3)); // => false +jxmValidator.isString(Object('3')); // => true ``` diff --git a/docs/en-US/APIs/isUnEmptyString.md b/docs/en-US/APIs/isUnEmptyString.md index 88376e3..d2686a9 100644 --- a/docs/en-US/APIs/isUnEmptyString.md +++ b/docs/en-US/APIs/isUnEmptyString.md @@ -39,13 +39,11 @@ jxmValidator.isUnEmptyString('3'); // => true jxmValidator.isUnEmptyString(0); // => false jxmValidator.isUnEmptyString(''); // => false -jxmValidator.isUnEmptyString('', {isStrict: false})); // => false - jxmValidator.isUnEmptyString(' '); // => false +jxmValidator.isUnEmptyString('', {isStrict: false})); // => false jxmValidator.isUnEmptyString(' ', {isStrict: false}); // => true jxmValidator.isUnEmptyString(null); // => false jxmValidator.isUnEmptyString(undefined); // => false - jxmValidator.isUnEmptyString(NaN); // => false ``` diff --git a/docs/en-US/APIs/isUnNegativeInteger.md b/docs/en-US/APIs/isUnNegativeInteger.md index 3bd81b5..af73ace 100644 --- a/docs/en-US/APIs/isUnNegativeInteger.md +++ b/docs/en-US/APIs/isUnNegativeInteger.md @@ -36,10 +36,18 @@ #### 示例: ```javascript +jxmValidator.isUnNegativeInteger(.3); // => false jxmValidator.isUnNegativeInteger(3); // => true +jxmValidator.isUnNegativeInteger(3.3); // => false +jxmValidator.isUnNegativeInteger('.3'); // => false jxmValidator.isUnNegativeInteger('3'); // => true +jxmValidator.isUnNegativeInteger('3.3'); // => false +jxmValidator.isUnNegativeInteger(.3, {isStrict: true}); // => false jxmValidator.isUnNegativeInteger(3, {isStrict: true}); // => true +jxmValidator.isUnNegativeInteger(3.3, {isStrict: true}); // => false +jxmValidator.isUnNegativeInteger('.3', {isStrict: true}); // => false jxmValidator.isUnNegativeInteger('3', {isStrict: true}); // => false +jxmValidator.isUnNegativeInteger('3.3', {isStrict: true}); // => false jxmValidator.isUnNegativeInteger(0); // => true jxmValidator.isUnNegativeIntegerv('0'); // => true @@ -51,16 +59,6 @@ jxmValidator.isUnNegativeInteger('-3'); // => false jxmValidator.isUnNegativeInteger(-3, {isStrict: true}); // => false jxmValidator.isUnNegativeInteger('-3', {isStrict: true}); // => false -jxmValidator.isUnNegativeInteger(3.3); // => false -jxmValidator.isUnNegativeInteger('3.3'); // => false -jxmValidator.isUnNegativeInteger(3.3, {isStrict: true}); // => false -jxmValidator.isUnNegativeInteger('3.3', {isStrict: true}); // => false - -jxmValidator.isUnNegativeInteger(-3.3); // => false -jxmValidator.isUnNegativeInteger('-3.3'); // => false -jxmValidator.isUnNegativeInteger(-3.3, {isStrict: true}); // => false -jxmValidator.isUnNegativeInteger('-3.3', {isStrict: true}); // => false - jxmValidator.isUnNegativeInteger(''); // => false jxmValidator.isUnNegativeInteger(' '); // => false jxmValidator.isUnNegativeInteger(null); // => false diff --git a/docs/en-US/APIs/isUnNegativeNumber.md b/docs/en-US/APIs/isUnNegativeNumber.md index f5ec662..70c67ad 100644 --- a/docs/en-US/APIs/isUnNegativeNumber.md +++ b/docs/en-US/APIs/isUnNegativeNumber.md @@ -34,12 +34,20 @@ > 若是非严格模式, 则该参数值校验后, 返回 true #### 示例: -s + ```javascript +jxmValidator.isUnNegativeNumber(.3); // => true jxmValidator.isUnNegativeNumber(3); // => true +jxmValidator.isUnNegativeNumber(3.5); // => true +jxmValidator.isUnNegativeNumber('.3'); // => true jxmValidator.isUnNegativeNumber('3'); // => true +jxmValidator.isUnNegativeNumber('3.5'); // => true +jxmValidator.isUnNegativeNumber(.3, {isStrict: true}); // => true jxmValidator.isUnNegativeNumber(3, {isStrict: true}); // => true +jxmValidator.isUnNegativeNumber(3.5, {isStrict: true}); // => true +jxmValidator.isUnNegativeNumber('.3', {isStrict: true}); // => false jxmValidator.isUnNegativeNumber('3', {isStrict: true}); // => false +jxmValidator.isUnNegativeNumber('3.5', {isStrict: true}); // => false jxmValidator.isUnNegativeNumber(0); // => true jxmValidator.isUnNegativeNumber('0'); // => true diff --git a/docs/en-US/APIs/isUnPositiveInteger.md b/docs/en-US/APIs/isUnPositiveInteger.md index 2505a6d..02f31d6 100644 --- a/docs/en-US/APIs/isUnPositiveInteger.md +++ b/docs/en-US/APIs/isUnPositiveInteger.md @@ -36,30 +36,28 @@ #### 示例: ```javascript -jxmValidator.isUnPositiveInteger(3); // => false -jxmValidator.isUnPositiveInteger('3'); // => false -jxmValidator.isUnPositiveInteger(3, {isStrict: true}); // => false -jxmValidator.isUnPositiveInteger('3', {isStrict: true}); // => false - -jxmValidator.isUnPositiveInteger(0); // => true -jxmValidator.isUnPositiveInteger('0'); // => true -jxmValidator.isUnPositiveInteger(0, {isStrict: true}); // => true -jxmValidator.isUnPositiveInteger('0', {isStrict: true}); // => false - +jxmValidator.isUnPositiveInteger(-.3); // => false jxmValidator.isUnPositiveInteger(-3); // => true +jxmValidator.isUnPositiveInteger(-3.3); // => false +jxmValidator.isUnPositiveInteger('-.3'); // => false jxmValidator.isUnPositiveInteger('-3'); // => true +jxmValidator.isUnPositiveInteger('-3.3'); // => false +jxmValidator.isUnPositiveInteger(-.3, {isStrict: true}); // => false jxmValidator.isUnPositiveInteger(-3, {isStrict: true}); // => true +jxmValidator.isUnPositiveInteger(-3.3, {isStrict: true}); // => false +jxmValidator.isUnPositiveInteger('-.3', {isStrict: true}); // => false jxmValidator.isUnPositiveInteger('-3', {isStrict: true}); // => false +jxmValidator.isUnPositiveInteger('-3.3', {isStrict: true}); // => false -jxmValidator.isUnPositiveInteger(3.3); // => false -jxmValidator.isUnPositiveInteger('3.3'); // => false -jxmValidator.isUnPositiveInteger(3.3, {isStrict: true}); // => false -jxmValidator.isUnPositiveInteger('3.3', {isStrict: true}); // => false +jxmValidator.isUnPositiveInteger(0); // => true +jxmValidator.isUnPositiveInteger('0'); // => true +jxmValidator.isUnPositiveInteger(0, {isStrict: true}); // => true +jxmValidator.isUnPositiveInteger('0', {isStrict: true}); // => false -jxmValidator.isUnPositiveInteger(-3.3); // => false -jxmValidator.isUnPositiveInteger('-3.3'); // => false -jxmValidator.isUnPositiveInteger(-3.3, {isStrict: true}); // => false -jxmValidator.isUnPositiveInteger('-3.3', {isStrict: true}); // => false +jxmValidator.isUnPositiveInteger(3); // => false +jxmValidator.isUnPositiveInteger('3'); // => false +jxmValidator.isUnPositiveInteger(3, {isStrict: true}); // => false +jxmValidator.isUnPositiveInteger('3', {isStrict: true}); // => false jxmValidator.isUnPositiveInteger(''); // => false jxmValidator.isUnPositiveInteger(' '); // => false diff --git a/docs/en-US/APIs/isUnPositiveNumber.md b/docs/en-US/APIs/isUnPositiveNumber.md index 364340e..d668e30 100644 --- a/docs/en-US/APIs/isUnPositiveNumber.md +++ b/docs/en-US/APIs/isUnPositiveNumber.md @@ -36,10 +36,18 @@ #### 示例: ```javascript +jxmValidator.isUnPositiveNumber(-.3); // => true jxmValidator.isUnPositiveNumber(-3); // => true +jxmValidator.isUnPositiveNumber(-3.5); // => true +jxmValidator.isUnPositiveNumber('-.3'); // => true jxmValidator.isUnPositiveNumber('-3'); // => true +jxmValidator.isUnPositiveNumber('-3.5'); // => true +jxmValidator.isUnPositiveNumber(-.3, {isStrict: true}); // => true jxmValidator.isUnPositiveNumber(-3, {isStrict: true}); // => true +jxmValidator.isUnPositiveNumber(-3.5, {isStrict: true}); // => true +jxmValidator.isUnPositiveNumber('-.3', {isStrict: true}); // => false jxmValidator.isUnPositiveNumber('-3', {isStrict: true}); // => false +jxmValidator.isUnPositiveNumber('-3.5', {isStrict: true}); // => false jxmValidator.isUnPositiveNumber(0); // => true jxmValidator.isUnPositiveNumber('0'); // => true diff --git a/docs/en-US/APIs/isUnZero.md b/docs/en-US/APIs/isUnZero.md index a10adb3..212ce1a 100644 --- a/docs/en-US/APIs/isUnZero.md +++ b/docs/en-US/APIs/isUnZero.md @@ -54,13 +54,8 @@ jxmValidator.isUnZero(' '); // => false jxmValidator.isUnZero(null); // => false jxmValidator.isUnZero(undefined); // => false -jxmValidator.isUnZero(Number(0)); // => false -jxmValidator.isUnZero(Number(3)); // => true -jxmValidator.isUnZero(new Number(0)); // => false -jxmValidator.isUnZero(new Number('0')); // => false -jxmValidator.isUnZero(new Number(3)); // => true - jxmValidator.isUnZero(Object(3)); // => true jxmValidator.isUnZero(Object('3')); // => true +jxmValidator.isUnZero(Object(3, {isStrict: true})); // => true jxmValidator.isUnZero(Object('3', {isStrict: true})); // => false ``` diff --git a/docs/en-US/APIs/isUndefined.md b/docs/en-US/APIs/isUndefined.md index 98005b9..032106b 100644 --- a/docs/en-US/APIs/isUndefined.md +++ b/docs/en-US/APIs/isUndefined.md @@ -18,6 +18,7 @@ ```javascript jxmValidator.isUndefined(undefined); // => true jxmValidator.isUndefined(null); // => false + jxmValidator.isUndefined(0); // => false jxmValidator.isUndefined(''); // => false jxmValidator.isUndefined('undefined'); // => false diff --git a/docs/en-US/APIs/isZero.md b/docs/en-US/APIs/isZero.md index ada2ed1..a38d164 100644 --- a/docs/en-US/APIs/isZero.md +++ b/docs/en-US/APIs/isZero.md @@ -51,10 +51,6 @@ jxmValidator.isZero(' '); // => false jxmValidator.isZero(null); // => false jxmValidator.isZero(undefined); // => false -jxmValidator.isZero(Number(0)); // => true -jxmValidator.isZero(new Number(0)); // => true -jxmValidator.isZero(new Number('0')); // => true - jxmValidator.isZero(Object(0)); // => true jxmValidator.isZero(Object('0')); // => true jxmValidator.isZero(Object('0', {isStrict: true})); // => false diff --git a/docs/zh-CN/APIs/isArray.md b/docs/zh-CN/APIs/isArray.md index 28b2cc5..6ae90fd 100644 --- a/docs/zh-CN/APIs/isArray.md +++ b/docs/zh-CN/APIs/isArray.md @@ -18,11 +18,10 @@ ```javascript jxmValidator.isArray([]); // => true jxmValidator.isArray({}); // => false -jxmValidator.isArray(parseInt); // => false jxmValidator.isArray(new Date()); // => false jxmValidator.isArray(null); // => false + jxmValidator.isArray(Object({})); // => false jxmValidator.isArray(Object([])); // => true -jxmValidator.isArray(new Object([])); // => true ``` diff --git a/docs/zh-CN/APIs/isBoolean.md b/docs/zh-CN/APIs/isBoolean.md index 88f36fd..c97ca3f 100644 --- a/docs/zh-CN/APIs/isBoolean.md +++ b/docs/zh-CN/APIs/isBoolean.md @@ -16,7 +16,6 @@ #### 示例: ```javascript -// boolean jxmValidator.isBoolean(true); // => true jxmValidator.isBoolean(false); // => true @@ -24,9 +23,5 @@ jxmValidator.isBoolean(0); // => false jxmValidator.isBoolean(''); // => false jxmValidator.isBoolean(null); // => false jxmValidator.isBoolean(undefined); // => false - -// boolean 包装对象 -jxmValidator.isBoolean(Boolean(true)); // => true -jxmValidator.isBoolean(new Boolean(true)); // => true jxmValidator.isBoolean({}); // => false ``` diff --git a/docs/zh-CN/APIs/isEmptyString.md b/docs/zh-CN/APIs/isEmptyString.md index 68731e0..cac5a47 100644 --- a/docs/zh-CN/APIs/isEmptyString.md +++ b/docs/zh-CN/APIs/isEmptyString.md @@ -40,13 +40,11 @@ jxmValidator.isEmptyString('3'); // => false jxmValidator.isEmptyString(0); // => false jxmValidator.isEmptyString(''); // => true -jxmValidator.isEmptyString('', {isStrict: false})); // => true - jxmValidator.isEmptyString(' '); // => true +jxmValidator.isEmptyString('', {isStrict: false})); // => true jxmValidator.isEmptyString(' ', {isStrict: false}); // => false jxmValidator.isEmptyString(null); // => false jxmValidator.isEmptyString(undefined); // => false - jxmValidator.isEmptyString(NaN); // => false ``` diff --git a/docs/zh-CN/APIs/isInfinity.md b/docs/zh-CN/APIs/isInfinity.md index 33412c2..4a37ef2 100644 --- a/docs/zh-CN/APIs/isInfinity.md +++ b/docs/zh-CN/APIs/isInfinity.md @@ -23,6 +23,7 @@ jxmValidator.isInfinity(NaN); // => false jxmValidator.isInfinity(null); // => false jxmValidator.isInfinity(undefined); // => false +jxmValidator.isInfinity(0); // => false jxmValidator.isInfinity(3); // => false jxmValidator.isInfinity(''); // => false ``` diff --git a/docs/zh-CN/APIs/isInteger.md b/docs/zh-CN/APIs/isInteger.md index 60d05eb..2249423 100644 --- a/docs/zh-CN/APIs/isInteger.md +++ b/docs/zh-CN/APIs/isInteger.md @@ -36,10 +36,18 @@ #### 示例: ```javascript +jxmValidator.isInteger(.3); // => false jxmValidator.isInteger(3); // => true +jxmValidator.isInteger(3.3); // => false +jxmValidator.isInteger('.3'); // => false jxmValidator.isInteger('3'); // => true +jxmValidator.isInteger('3.3'); // => false +jxmValidator.isInteger(.3, {isStrict: true}); // => false jxmValidator.isInteger(3, {isStrict: true}); // => true +jxmValidator.isInteger(3.3, {isStrict: true}); // => false +jxmValidator.isInteger('.3', {isStrict: true}); // => false jxmValidator.isInteger('3', {isStrict: true}); // => false +jxmValidator.isInteger('3.3', {isStrict: true}); // => false jxmValidator.isInteger(0); // => true jxmValidator.isInteger('0'); // => true @@ -51,16 +59,6 @@ jxmValidator.isInteger('-3'); // => true jxmValidator.isInteger(-3, {isStrict: true}); // => true jxmValidator.isInteger('-3', {isStrict: true}); // => false -jxmValidator.isInteger(3.3); // => false -jxmValidator.isInteger('3.3'); // => false -jxmValidator.isInteger(3.3, {isStrict: true}); // => false -jxmValidator.isInteger('3.3', {isStrict: true}); // => false - -jxmValidator.isInteger(-3.3); // => false -jxmValidator.isInteger('-3.3'); // => false -jxmValidator.isInteger(-3.3, {isStrict: true}); // => false -jxmValidator.isInteger('-3.3', {isStrict: true}); // => false - jxmValidator.isInteger(''); // => false jxmValidator.isInteger(' '); // => false jxmValidator.isInteger(null); // => false diff --git a/docs/zh-CN/APIs/isNegativeInteger.md b/docs/zh-CN/APIs/isNegativeInteger.md index 95ee1d8..0023fc8 100644 --- a/docs/zh-CN/APIs/isNegativeInteger.md +++ b/docs/zh-CN/APIs/isNegativeInteger.md @@ -36,30 +36,28 @@ #### 示例: ```javascript -jxmValidator.isNegativeInteger(3); // => false -jxmValidator.isNegativeInteger('3'); // => false -jxmValidator.isNegativeInteger(3, {isStrict: true}); // => false -jxmValidator.isNegativeInteger('3', {isStrict: true}); // => false - -jxmValidator.isNegativeInteger(0); // => false -jxmValidator.isNegativeInteger('0'); // => false -jxmValidator.isNegativeInteger(0, {isStrict: true}); // => false -jxmValidator.isNegativeInteger('0', {isStrict: true}); // => false - +jxmValidator.isNegativeInteger(-.3); // => false jxmValidator.isNegativeInteger(-3); // => true +jxmValidator.isNegativeInteger(-3.3); // => false +jxmValidator.isNegativeInteger('-.3'); // => false jxmValidator.isNegativeInteger('-3'); // => true +jxmValidator.isNegativeInteger('-3.3'); // => false +jxmValidator.isNegativeInteger(-.3, {isStrict: true}); // => false jxmValidator.isNegativeInteger(-3, {isStrict: true}); // => true +jxmValidator.isNegativeInteger(-3.3, {isStrict: true}); // => false +jxmValidator.isNegativeInteger('-.3', {isStrict: true}); // => false jxmValidator.isNegativeInteger('-3', {isStrict: true}); // => false +jxmValidator.isNegativeInteger('-3.3', {isStrict: true}); // => false -jxmValidator.isNegativeInteger(3.3); // => false -jxmValidator.isNegativeInteger('3.3'); // => false -jxmValidator.isNegativeInteger(3.3, {isStrict: true}); // => false -jxmValidator.isNegativeInteger('3.3', {isStrict: true}); // => false +jxmValidator.isNegativeInteger(0); // => false +jxmValidator.isNegativeInteger('0'); // => false +jxmValidator.isNegativeInteger(0, {isStrict: true}); // => false +jxmValidator.isNegativeInteger('0', {isStrict: true}); // => false -jxmValidator.isNegativeInteger(-3.3); // => false -jxmValidator.isNegativeInteger('-3.3'); // => false -jxmValidator.isNegativeInteger(-3.3, {isStrict: true}); // => false -jxmValidator.isNegativeInteger('-3.3', {isStrict: true}); // => false +jxmValidator.isNegativeInteger(3); // => false +jxmValidator.isNegativeInteger('3'); // => false +jxmValidator.isNegativeInteger(3, {isStrict: true}); // => false +jxmValidator.isNegativeInteger('3', {isStrict: true}); // => false jxmValidator.isNegativeInteger(''); // => false jxmValidator.isNegativeInteger(' '); // => false diff --git a/docs/zh-CN/APIs/isNegativeNumber.md b/docs/zh-CN/APIs/isNegativeNumber.md index 867576d..acba38f 100644 --- a/docs/zh-CN/APIs/isNegativeNumber.md +++ b/docs/zh-CN/APIs/isNegativeNumber.md @@ -36,10 +36,18 @@ #### 示例: ```javascript +jxmValidator.isNegativeNumber(-.3); // => true jxmValidator.isNegativeNumber(-3); // => true +jxmValidator.isNegativeNumber(-3.5); // => true +jxmValidator.isNegativeNumber('-.3'); // => true jxmValidator.isNegativeNumber('-3'); // => true +jxmValidator.isNegativeNumber('-3.5'); // => true +jxmValidator.isNegativeNumber(-.3, {isStrict: true}); // => true jxmValidator.isNegativeNumber(-3, {isStrict: true}); // => true +jxmValidator.isNegativeNumber(-3.5, {isStrict: true}); // => true +jxmValidator.isNegativeNumber('-.3', {isStrict: true}); // => false jxmValidator.isNegativeNumber('-3', {isStrict: true}); // => false +jxmValidator.isNegativeNumber('-3.5', {isStrict: true}); // => false jxmValidator.isNegativeNumber(0); // => false jxmValidator.isNegativeNumber('0'); // => false diff --git a/docs/zh-CN/APIs/isNumber.md b/docs/zh-CN/APIs/isNumber.md index 27da65c..0256224 100644 --- a/docs/zh-CN/APIs/isNumber.md +++ b/docs/zh-CN/APIs/isNumber.md @@ -13,12 +13,11 @@ 当参数 val 为 `number` 时,返回 `true`, 否则返回 `false` - * number 类型还包括: NaN, Infinity, -Infinity + * number 类型还包括: NaN, Infinity, -Infinity, ... #### 示例: ```javascript -// number jxmValidator.isNumber(3); // => true jxmValidator.isNumber('3'); // => false @@ -30,12 +29,5 @@ jxmValidator.isNumber(''); // => false jxmValidator.isNumber(true); // => false jxmValidator.isNumber(null); // => false jxmValidator.isNumber(undefined); // => false - -// number 包装对象 -jxmValidator.isNumber(Number(3)); // => true -jxmValidator.isNumber(new Number(3)); // => true - jxmValidator.isNumber({}); // => false -jxmValidator.isNumber(Object(3)); // => true -jxmValidator.isNumber(Object('3')); // => false ``` diff --git a/docs/zh-CN/APIs/isNumeric.md b/docs/zh-CN/APIs/isNumeric.md index d252f81..0b161f3 100644 --- a/docs/zh-CN/APIs/isNumeric.md +++ b/docs/zh-CN/APIs/isNumeric.md @@ -51,10 +51,7 @@ jxmValidator.isNumeric(' '); // => false jxmValidator.isNumeric(null); // => false jxmValidator.isNumeric(undefined); // => false -jxmValidator.isNumeric(Number(3)); // => true -jxmValidator.isNumeric(new Number(3)); // => true jxmValidator.isNumeric({}); // => false - jxmValidator.isNumeric(Object(3)); // => true jxmValidator.isNumeric(Object('3')); // => true jxmValidator.isNumeric(Object('3', {isStrict: true})); // => false diff --git a/docs/zh-CN/APIs/isObject.md b/docs/zh-CN/APIs/isObject.md index ffa0379..6b61c76 100644 --- a/docs/zh-CN/APIs/isObject.md +++ b/docs/zh-CN/APIs/isObject.md @@ -21,9 +21,8 @@ jxmValidator.isObject([]); // => false jxmValidator.isObject(parseInt); // => false jxmValidator.isObject(new Date()); // => false +jxmValidator.isObject(Object('3')); // => false jxmValidator.isObject(Object({})); // => true -jxmValidator.isObject(Object('3'); // => false -jxmValidator.isObject(new Object('3')); // => false jxmValidator.isObject(null); // => false jxmValidator.isObject(Object.create(null)); // => true diff --git a/docs/zh-CN/APIs/isPlainObject.md b/docs/zh-CN/APIs/isPlainObject.md index 0a9a692..0a2249c 100644 --- a/docs/zh-CN/APIs/isPlainObject.md +++ b/docs/zh-CN/APIs/isPlainObject.md @@ -21,9 +21,9 @@ jxmValidator.isPlainObject([]); // => false jxmValidator.isPlainObject(parseInt); // => false jxmValidator.isPlainObject(new Date()); // => false -jxmValidator.isPlainObject(Object({})); // => true jxmValidator.isPlainObject(Object('3'); // => false -jxmValidator.isPlainObject(new Object('3'); // => false +jxmValidator.isPlainObject(Object([])); // => false +jxmValidator.isPlainObject(Object({})); // => true jxmValidator.isPlainObject(null); // => false jxmValidator.isPlainObject(Object.create(null)); // => true diff --git a/docs/zh-CN/APIs/isPositiveInteger.md b/docs/zh-CN/APIs/isPositiveInteger.md index 9df6985..9b0582f 100644 --- a/docs/zh-CN/APIs/isPositiveInteger.md +++ b/docs/zh-CN/APIs/isPositiveInteger.md @@ -36,10 +36,18 @@ #### 示例: ```javascript +jxmValidator.isPositiveInteger(.3); // => false jxmValidator.isPositiveInteger(3); // => true +jxmValidator.isPositiveInteger(3.3); // => false +jxmValidator.isPositiveInteger('.3'); // => false jxmValidator.isPositiveInteger('3'); // => true +jxmValidator.isPositiveInteger('3.3'); // => false +jxmValidator.isPositiveInteger(.3, {isStrict: true}); // => false jxmValidator.isPositiveInteger(3, {isStrict: true}); // => true +jxmValidator.isPositiveInteger(3.3, {isStrict: true}); // => false +jxmValidator.isPositiveInteger('.3', {isStrict: true}); // => false jxmValidator.isPositiveInteger('3', {isStrict: true}); // => false +jxmValidator.isPositiveInteger('3.3', {isStrict: true}); // => false jxmValidator.isPositiveInteger(0); // => false jxmValidator.isPositiveInteger('0'); // => false @@ -51,16 +59,6 @@ jxmValidator.isPositiveInteger('-3'); // => false jxmValidator.isPositiveInteger(-3, {isStrict: true}); // => false jxmValidator.isPositiveInteger('-3', {isStrict: true}); // => false -jxmValidator.isPositiveInteger(3.3); // => false -jxmValidator.isPositiveInteger('3.3'); // => false -jxmValidator.isPositiveInteger(3.3, {isStrict: true}); // => false -jxmValidator.isPositiveInteger('3.3', {isStrict: true}); // => false - -jxmValidator.isPositiveInteger(-3.3); // => false -jxmValidator.isPositiveInteger('-3.3'); // => false -jxmValidator.isPositiveInteger(-3.3, {isStrict: true}); // => false -jxmValidator.isPositiveInteger('-3.3', {isStrict: true}); // => false - jxmValidator.isPositiveInteger(''); // => false jxmValidator.isPositiveInteger(' '); // => false jxmValidator.isPositiveInteger(null); // => false diff --git a/docs/zh-CN/APIs/isPositiveNumber.md b/docs/zh-CN/APIs/isPositiveNumber.md index a29a723..7c2cbe0 100644 --- a/docs/zh-CN/APIs/isPositiveNumber.md +++ b/docs/zh-CN/APIs/isPositiveNumber.md @@ -36,10 +36,18 @@ #### 示例: ```javascript +jxmValidator.isPositiveNumber(.3); // => true jxmValidator.isPositiveNumber(3); // => true +jxmValidator.isPositiveNumber(3.5); // => true +jxmValidator.isPositiveNumber('.3'); // => true jxmValidator.isPositiveNumber('3'); // => true +jxmValidator.isPositiveNumber('3.5'); // => true +jxmValidator.isPositiveNumber(.3, {isStrict: true}); // => true jxmValidator.isPositiveNumber(3, {isStrict: true}); // => true +jxmValidator.isPositiveNumber(3.5, {isStrict: true}); // => true +jxmValidator.isPositiveNumber('.3', {isStrict: true}); // => false jxmValidator.isPositiveNumber('3', {isStrict: true}); // => false +jxmValidator.isPositiveNumber('3.5', {isStrict: true}); // => false jxmValidator.isPositiveNumber(0); // => false jxmValidator.isPositiveNumber('0'); // => false @@ -49,7 +57,7 @@ jxmValidator.isPositiveNumber('0', {isStrict: true}); // => false jxmValidator.isPositiveNumber(-3); // => false jxmValidator.isPositiveNumber('-3'); // => false jxmValidator.isPositiveNumber(-3, {isStrict: true}); // => false -jxmValidator.isPositiveNumber('3', {isStrict: true}); // => false +jxmValidator.isPositiveNumber('-3', {isStrict: true}); // => false jxmValidator.isPositiveNumber(''); // => false jxmValidator.isPositiveNumber(' '); // => false diff --git a/docs/zh-CN/APIs/isRealNumber.md b/docs/zh-CN/APIs/isRealNumber.md index beb5fd7..167894f 100644 --- a/docs/zh-CN/APIs/isRealNumber.md +++ b/docs/zh-CN/APIs/isRealNumber.md @@ -51,9 +51,6 @@ jxmValidator.isRealNumber(' '); // => false jxmValidator.isRealNumber(null); // => false jxmValidator.isRealNumber(undefined); // => false -jxmValidator.isRealNumber(Number(3)); // => true -jxmValidator.isRealNumber(new Number(3)); // => true - jxmValidator.isRealNumber({}); // => false jxmValidator.isRealNumber(Object(3)); // => true jxmValidator.isRealNumber(Object('3')); // => true diff --git a/docs/zh-CN/APIs/isString.md b/docs/zh-CN/APIs/isString.md index f3a8674..0c927de 100644 --- a/docs/zh-CN/APIs/isString.md +++ b/docs/zh-CN/APIs/isString.md @@ -16,7 +16,6 @@ #### 示例: ```javascript -// string jxmValidator.isString(''); // => true jxmValidator.isString(' '); // => true @@ -27,11 +26,8 @@ jxmValidator.isString(true); // => false jxmValidator.isString(null); // => false jxmValidator.isString(undefined); // => false -// string 包装对象 -jxmValidator.isString(String(3)); // => true -jxmValidator.isString(new String(3)); // => true - jxmValidator.isString({}); // => false -jxmValidator.isString(Object('3')); // => true + jxmValidator.isString(Object(3)); // => false +jxmValidator.isString(Object('3')); // => true ``` diff --git a/docs/zh-CN/APIs/isUnEmptyString.md b/docs/zh-CN/APIs/isUnEmptyString.md index 88376e3..d2686a9 100644 --- a/docs/zh-CN/APIs/isUnEmptyString.md +++ b/docs/zh-CN/APIs/isUnEmptyString.md @@ -39,13 +39,11 @@ jxmValidator.isUnEmptyString('3'); // => true jxmValidator.isUnEmptyString(0); // => false jxmValidator.isUnEmptyString(''); // => false -jxmValidator.isUnEmptyString('', {isStrict: false})); // => false - jxmValidator.isUnEmptyString(' '); // => false +jxmValidator.isUnEmptyString('', {isStrict: false})); // => false jxmValidator.isUnEmptyString(' ', {isStrict: false}); // => true jxmValidator.isUnEmptyString(null); // => false jxmValidator.isUnEmptyString(undefined); // => false - jxmValidator.isUnEmptyString(NaN); // => false ``` diff --git a/docs/zh-CN/APIs/isUnNegativeInteger.md b/docs/zh-CN/APIs/isUnNegativeInteger.md index 3bd81b5..af73ace 100644 --- a/docs/zh-CN/APIs/isUnNegativeInteger.md +++ b/docs/zh-CN/APIs/isUnNegativeInteger.md @@ -36,10 +36,18 @@ #### 示例: ```javascript +jxmValidator.isUnNegativeInteger(.3); // => false jxmValidator.isUnNegativeInteger(3); // => true +jxmValidator.isUnNegativeInteger(3.3); // => false +jxmValidator.isUnNegativeInteger('.3'); // => false jxmValidator.isUnNegativeInteger('3'); // => true +jxmValidator.isUnNegativeInteger('3.3'); // => false +jxmValidator.isUnNegativeInteger(.3, {isStrict: true}); // => false jxmValidator.isUnNegativeInteger(3, {isStrict: true}); // => true +jxmValidator.isUnNegativeInteger(3.3, {isStrict: true}); // => false +jxmValidator.isUnNegativeInteger('.3', {isStrict: true}); // => false jxmValidator.isUnNegativeInteger('3', {isStrict: true}); // => false +jxmValidator.isUnNegativeInteger('3.3', {isStrict: true}); // => false jxmValidator.isUnNegativeInteger(0); // => true jxmValidator.isUnNegativeIntegerv('0'); // => true @@ -51,16 +59,6 @@ jxmValidator.isUnNegativeInteger('-3'); // => false jxmValidator.isUnNegativeInteger(-3, {isStrict: true}); // => false jxmValidator.isUnNegativeInteger('-3', {isStrict: true}); // => false -jxmValidator.isUnNegativeInteger(3.3); // => false -jxmValidator.isUnNegativeInteger('3.3'); // => false -jxmValidator.isUnNegativeInteger(3.3, {isStrict: true}); // => false -jxmValidator.isUnNegativeInteger('3.3', {isStrict: true}); // => false - -jxmValidator.isUnNegativeInteger(-3.3); // => false -jxmValidator.isUnNegativeInteger('-3.3'); // => false -jxmValidator.isUnNegativeInteger(-3.3, {isStrict: true}); // => false -jxmValidator.isUnNegativeInteger('-3.3', {isStrict: true}); // => false - jxmValidator.isUnNegativeInteger(''); // => false jxmValidator.isUnNegativeInteger(' '); // => false jxmValidator.isUnNegativeInteger(null); // => false diff --git a/docs/zh-CN/APIs/isUnNegativeNumber.md b/docs/zh-CN/APIs/isUnNegativeNumber.md index f5ec662..70c67ad 100644 --- a/docs/zh-CN/APIs/isUnNegativeNumber.md +++ b/docs/zh-CN/APIs/isUnNegativeNumber.md @@ -34,12 +34,20 @@ > 若是非严格模式, 则该参数值校验后, 返回 true #### 示例: -s + ```javascript +jxmValidator.isUnNegativeNumber(.3); // => true jxmValidator.isUnNegativeNumber(3); // => true +jxmValidator.isUnNegativeNumber(3.5); // => true +jxmValidator.isUnNegativeNumber('.3'); // => true jxmValidator.isUnNegativeNumber('3'); // => true +jxmValidator.isUnNegativeNumber('3.5'); // => true +jxmValidator.isUnNegativeNumber(.3, {isStrict: true}); // => true jxmValidator.isUnNegativeNumber(3, {isStrict: true}); // => true +jxmValidator.isUnNegativeNumber(3.5, {isStrict: true}); // => true +jxmValidator.isUnNegativeNumber('.3', {isStrict: true}); // => false jxmValidator.isUnNegativeNumber('3', {isStrict: true}); // => false +jxmValidator.isUnNegativeNumber('3.5', {isStrict: true}); // => false jxmValidator.isUnNegativeNumber(0); // => true jxmValidator.isUnNegativeNumber('0'); // => true diff --git a/docs/zh-CN/APIs/isUnPositiveInteger.md b/docs/zh-CN/APIs/isUnPositiveInteger.md index 2505a6d..02f31d6 100644 --- a/docs/zh-CN/APIs/isUnPositiveInteger.md +++ b/docs/zh-CN/APIs/isUnPositiveInteger.md @@ -36,30 +36,28 @@ #### 示例: ```javascript -jxmValidator.isUnPositiveInteger(3); // => false -jxmValidator.isUnPositiveInteger('3'); // => false -jxmValidator.isUnPositiveInteger(3, {isStrict: true}); // => false -jxmValidator.isUnPositiveInteger('3', {isStrict: true}); // => false - -jxmValidator.isUnPositiveInteger(0); // => true -jxmValidator.isUnPositiveInteger('0'); // => true -jxmValidator.isUnPositiveInteger(0, {isStrict: true}); // => true -jxmValidator.isUnPositiveInteger('0', {isStrict: true}); // => false - +jxmValidator.isUnPositiveInteger(-.3); // => false jxmValidator.isUnPositiveInteger(-3); // => true +jxmValidator.isUnPositiveInteger(-3.3); // => false +jxmValidator.isUnPositiveInteger('-.3'); // => false jxmValidator.isUnPositiveInteger('-3'); // => true +jxmValidator.isUnPositiveInteger('-3.3'); // => false +jxmValidator.isUnPositiveInteger(-.3, {isStrict: true}); // => false jxmValidator.isUnPositiveInteger(-3, {isStrict: true}); // => true +jxmValidator.isUnPositiveInteger(-3.3, {isStrict: true}); // => false +jxmValidator.isUnPositiveInteger('-.3', {isStrict: true}); // => false jxmValidator.isUnPositiveInteger('-3', {isStrict: true}); // => false +jxmValidator.isUnPositiveInteger('-3.3', {isStrict: true}); // => false -jxmValidator.isUnPositiveInteger(3.3); // => false -jxmValidator.isUnPositiveInteger('3.3'); // => false -jxmValidator.isUnPositiveInteger(3.3, {isStrict: true}); // => false -jxmValidator.isUnPositiveInteger('3.3', {isStrict: true}); // => false +jxmValidator.isUnPositiveInteger(0); // => true +jxmValidator.isUnPositiveInteger('0'); // => true +jxmValidator.isUnPositiveInteger(0, {isStrict: true}); // => true +jxmValidator.isUnPositiveInteger('0', {isStrict: true}); // => false -jxmValidator.isUnPositiveInteger(-3.3); // => false -jxmValidator.isUnPositiveInteger('-3.3'); // => false -jxmValidator.isUnPositiveInteger(-3.3, {isStrict: true}); // => false -jxmValidator.isUnPositiveInteger('-3.3', {isStrict: true}); // => false +jxmValidator.isUnPositiveInteger(3); // => false +jxmValidator.isUnPositiveInteger('3'); // => false +jxmValidator.isUnPositiveInteger(3, {isStrict: true}); // => false +jxmValidator.isUnPositiveInteger('3', {isStrict: true}); // => false jxmValidator.isUnPositiveInteger(''); // => false jxmValidator.isUnPositiveInteger(' '); // => false diff --git a/docs/zh-CN/APIs/isUnPositiveNumber.md b/docs/zh-CN/APIs/isUnPositiveNumber.md index 364340e..d668e30 100644 --- a/docs/zh-CN/APIs/isUnPositiveNumber.md +++ b/docs/zh-CN/APIs/isUnPositiveNumber.md @@ -36,10 +36,18 @@ #### 示例: ```javascript +jxmValidator.isUnPositiveNumber(-.3); // => true jxmValidator.isUnPositiveNumber(-3); // => true +jxmValidator.isUnPositiveNumber(-3.5); // => true +jxmValidator.isUnPositiveNumber('-.3'); // => true jxmValidator.isUnPositiveNumber('-3'); // => true +jxmValidator.isUnPositiveNumber('-3.5'); // => true +jxmValidator.isUnPositiveNumber(-.3, {isStrict: true}); // => true jxmValidator.isUnPositiveNumber(-3, {isStrict: true}); // => true +jxmValidator.isUnPositiveNumber(-3.5, {isStrict: true}); // => true +jxmValidator.isUnPositiveNumber('-.3', {isStrict: true}); // => false jxmValidator.isUnPositiveNumber('-3', {isStrict: true}); // => false +jxmValidator.isUnPositiveNumber('-3.5', {isStrict: true}); // => false jxmValidator.isUnPositiveNumber(0); // => true jxmValidator.isUnPositiveNumber('0'); // => true diff --git a/docs/zh-CN/APIs/isUnZero.md b/docs/zh-CN/APIs/isUnZero.md index a10adb3..212ce1a 100644 --- a/docs/zh-CN/APIs/isUnZero.md +++ b/docs/zh-CN/APIs/isUnZero.md @@ -54,13 +54,8 @@ jxmValidator.isUnZero(' '); // => false jxmValidator.isUnZero(null); // => false jxmValidator.isUnZero(undefined); // => false -jxmValidator.isUnZero(Number(0)); // => false -jxmValidator.isUnZero(Number(3)); // => true -jxmValidator.isUnZero(new Number(0)); // => false -jxmValidator.isUnZero(new Number('0')); // => false -jxmValidator.isUnZero(new Number(3)); // => true - jxmValidator.isUnZero(Object(3)); // => true jxmValidator.isUnZero(Object('3')); // => true +jxmValidator.isUnZero(Object(3, {isStrict: true})); // => true jxmValidator.isUnZero(Object('3', {isStrict: true})); // => false ``` diff --git a/docs/zh-CN/APIs/isUndefined.md b/docs/zh-CN/APIs/isUndefined.md index 98005b9..032106b 100644 --- a/docs/zh-CN/APIs/isUndefined.md +++ b/docs/zh-CN/APIs/isUndefined.md @@ -18,6 +18,7 @@ ```javascript jxmValidator.isUndefined(undefined); // => true jxmValidator.isUndefined(null); // => false + jxmValidator.isUndefined(0); // => false jxmValidator.isUndefined(''); // => false jxmValidator.isUndefined('undefined'); // => false diff --git a/docs/zh-CN/APIs/isZero.md b/docs/zh-CN/APIs/isZero.md index ada2ed1..a38d164 100644 --- a/docs/zh-CN/APIs/isZero.md +++ b/docs/zh-CN/APIs/isZero.md @@ -51,10 +51,6 @@ jxmValidator.isZero(' '); // => false jxmValidator.isZero(null); // => false jxmValidator.isZero(undefined); // => false -jxmValidator.isZero(Number(0)); // => true -jxmValidator.isZero(new Number(0)); // => true -jxmValidator.isZero(new Number('0')); // => true - jxmValidator.isZero(Object(0)); // => true jxmValidator.isZero(Object('0')); // => true jxmValidator.isZero(Object('0', {isStrict: true})); // => false diff --git a/package.json b/package.json index 4b732a2..30c2de9 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,18 @@ { "name": "jxm-validator", - "version": "0.0.6", + "version": "0.0.7", "description": "A modern JavaScript verification toolkit library", "main": "validator.js", "scripts": { - "build": "npm run jxmEslint && npm run jxmTest && npm run jxmBuild", - "build:uglify": "npm run jxmEslint && npm run jxmTest && npm run jxmUglify", - "jxmBuild": "webpack --config webpack.config.js", - "jxmUglify": "webpack --config webpack.config.uglify.js", - "jxmTest": "mocha ./test/*.test.js", - "jxmCoverage": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec", - "jxmCoverage:build": "istanbul cover _mocha -- -R spec --timeout 5000 --recursive", - "jxmCoverage:check": "istanbul check-coverage", - "jxmEslint": "eslint --config .eslintrc.yaml * --ignore-path .eslintignore --quiet" + "build": "npm run eslint && npm run test && npm run webpack:pack", + "build:uglify": "npm run eslint && npm run test && npm run webpack:uglify", + "webpack:pack": "webpack --config webpack.config.js", + "webpack:uglify": "webpack --config webpack.config.uglify.js", + "eslint": "eslint . --quiet", + "test": "mocha ./test/**/*.test.js", + "test:coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec", + "test:coverage:build": "istanbul cover _mocha -- -R spec --timeout 5000 --recursive", + "test:coverage:check": "istanbul check-coverage" }, "repository": { "type": "git", diff --git a/src/internal/enum/dataTypeEnum.js b/src/internal/enum/dataTypeEnum.js index 893634d..b69da31 100644 --- a/src/internal/enum/dataTypeEnum.js +++ b/src/internal/enum/dataTypeEnum.js @@ -1,5 +1,5 @@ -// Js数据类型 +// Js 数据类型 var DATA_TYPE_ENUM = {}; // 存储类型 diff --git a/src/internal/enum/regexEnum.js b/src/internal/enum/regexEnum.js index e3466f6..fe30b46 100644 --- a/src/internal/enum/regexEnum.js +++ b/src/internal/enum/regexEnum.js @@ -1,18 +1,21 @@ // 正则表达式 var REGEX_ENUM = { + // POSITIVE_NUMBER_REX: /^[1-9]\d*((\.\d+))?$|^0?\.\d*[1-9]\d*$/, // 正数 + POSITIVE_NUMBER_REX: /^[1-9]\d*(\.\d*)?$|^0?\.\d*[1-9]\d*$/, // 正数 + NEGATIVE_NUMBER_REX: /^-[1-9]\d*(\.\d*)?$|^-0?\.\d*[1-9]\d*$/, // 负数 + // UN_POSITIVE_NUMBER_REX: /^-[1-9]\d*(\.\d*)?$|^-0?\.\d*[1-9]\d*$|^0*(.)?0*$/, // 非正数 + // UN_NEGATIVE_NUMBER_REX: /^[1-9]\d*(\.\d*)?$|^0?\.\d*[1-9]\d*$|^0*(.)?0*$/, // 非负数 + INTEGER_REX: /^-?\d+$/, // 整数 POSITIVE_INTEGER_REX: /^[1-9]\d*$/, // 正整数 NEGATIVE_INTEGER_REX: /^-[1-9]\d*$/, // 负整数 UN_POSITIVE_INTEGER_REX: /^-[1-9]\d*$|^0$/, // 非正整数 UN_NEGATIVE_INTEGER_REX: /^[1-9]\d*$|^0$/, // 非负整数 - POSITIVE_NUMBER_REX: /^[1-9]\d*(\.\d)*$|^0\.\d*[1-9]\d*$/, // 正数 - NEGATIVE_NUMBER_REX: /^-[1-9]\d*(\.\d)*$|^-0\.\d*[1-9]\d*$/, // 负数 - UN_NEGATIVE_NUMBER_REX: /^[1-9]\d*(\.\d)*$|^0\.\d*[1-9]\d*$|^0$/, // 非负数 - UN_POSITIVE_NUMBER_REX: /^-[1-9]\d*(\.\d)*$|^-0\.\d*[1-9]\d*$|^0$/, // 非正数 + LEFT_WHITE_SPACE_REX: /^\s\s*/, // 左空白 + RIGHT_WHITE_SPACE_REX: /\s\s*$/, // 右空白 - EMAIL_REX: /^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/, // 邮箱 TELEPHONE_REX: { // 座机 'zh-CN': /^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/ }, @@ -20,6 +23,9 @@ var REGEX_ENUM = { 'zh-CN': /^(\+?0?86-?)?1\d{10}$/ }, + // 邮箱 + EMAIL_REX: /^[a-zA-Z0-9]+([._\\-]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/, + // ipv4 IPV4_REX: /\b((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])\.((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])\.((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])\.((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])\b/ }; diff --git a/src/isEmptyString.js b/src/isEmptyString.js index 4e60ad0..daf6e6b 100644 --- a/src/isEmptyString.js +++ b/src/isEmptyString.js @@ -12,8 +12,7 @@ var _isObject = require('./isObject'); * 若参数 `val` 不是 string, 则直接返回 false * 若参数 `val` 是 string, 并且为空,则返回 true, 否则, 返回 false * - * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, - * 则会对参数 `val` 进行两端去除空白(空字符),之后在校验其是否为空字符串 + * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则会对参数 `val` 进行两端去除空白(空字符),之后在校验其是否为空字符串 * * e.g. * @@ -25,7 +24,7 @@ var _isObject = require('./isObject'); * @param {Object} options 可选参数 * @param {Boolean} options.isStrict 是否严格模式 * @return {Boolean} 返回校验结果 - * @version 0.0.5 + * @version 0.0.7 * @since 0.0.5 */ function _isEmptyString(val, options) { @@ -35,7 +34,15 @@ function _isEmptyString(val, options) { return false; } - return opts.isStrict === false ? val === '' : (val.trim() === ''); + if (opts.isStrict === false) { + return val === ''; + } + + // @TODO + // 引用: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim + // String.prototype.trim, 在 ECMAScript 5.1 定义, 在 JavaScript 1.8.1 实现 + // return val.replace(REGEX_ENUM.LEFT_WHITE_SPACE_REX, '').replace(REGEX_ENUM.RIGHT_WHITE_SPACE_REX, '') === ''; + return val.trim() === ''; } module.exports = _isEmptyString; diff --git a/src/isJSON.js b/src/isJSON.js index a37cb00..58d23ed 100644 --- a/src/isJSON.js +++ b/src/isJSON.js @@ -18,6 +18,9 @@ function _isJSON(val) { } try { + // @TODO + // 引用: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse + // JSON support, 在 ECMAScript 5.1 定义, 在 JavaScript 1.7 实现 var jsonObj = JSON.parse(val); return _isPlainObject(jsonObj); diff --git a/src/isNaN.js b/src/isNaN.js index a4f66a1..47c54c7 100644 --- a/src/isNaN.js +++ b/src/isNaN.js @@ -11,7 +11,6 @@ */ function _isNaN(val) { // @TODO - // // 引用: ECMAScript5.1 15章节 [15.1.2.4](https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.2.4) // 全局对象函数 isNaN 存在如下怪异行为: 它总是先将参数转化成数字,然后再来判断是否是 NaN // 因此,会导致问题: @@ -19,11 +18,13 @@ function _isNaN(val) { // <=> isNaN(Number('foo')); // => true // // 解决方案: 使用 `!==`, NaN 是唯一一个不与自身恒等 + // 引用: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/NaN + // + // 从 ES6 开始,Number 提供了 Number.isNaN 来判断是否为 NaN // - // 从ES6开始,Number提供了 Number.isNaN 来判断是否为 NaN - // e.g: - // Number.isNaN('foo'); // => false - // Number.isNaN(NaN); // => true + // e.g. + // Number.isNaN('foo'); // => false + // Number.isNaN(NaN); // => true // return val !== val; } diff --git a/src/isNegativeNumber.js b/src/isNegativeNumber.js index 4ac0fa7..4769895 100644 --- a/src/isNegativeNumber.js +++ b/src/isNegativeNumber.js @@ -28,7 +28,7 @@ var REGEX_ENUM = require('./internal/enum/regexEnum'); * @param {Object} options 可选参数 * @param {Boolean} options.isStrict 是否严格模式 * @return {Boolean} 返回校验结果 - * @version 0.0.5 + * @version 0.0.7 * @since 0.0.4 */ function _isNegativeNumber(val, options) { diff --git a/src/isPositiveNumber.js b/src/isPositiveNumber.js index 6eb1d13..ddf27f5 100644 --- a/src/isPositiveNumber.js +++ b/src/isPositiveNumber.js @@ -28,7 +28,7 @@ var REGEX_ENUM = require('./internal/enum/regexEnum'); * @param {Object} options 可选参数 * @param {Boolean} options.isStrict 是否严格模式 * @return {Boolean} 返回校验结果 - * @version 0.0.5 + * @version 0.0.7 * @since 0.0.4 */ function _isPositiveNumber(val, options) { diff --git a/src/isRealNumber.js b/src/isRealNumber.js index 52305fc..2d321bb 100644 --- a/src/isRealNumber.js +++ b/src/isRealNumber.js @@ -39,7 +39,7 @@ function _isRealNumber(val, options) { return !_isNaN(val); } - // 若是非严格模式, 则对字符串 '3' 进行判定, 需要排除 ' ' 字符串 + // 若是非严格模式, 则对字符串 '3' 进行判定, 需要排除 '', ' ' 字符串 if (opts.isStrict !== true && _isUnEmptyString(val, {isStrict: true})) { var detal = val - 0; diff --git a/src/isUnEmptyString.js b/src/isUnEmptyString.js index 3325a93..7da4c21 100644 --- a/src/isUnEmptyString.js +++ b/src/isUnEmptyString.js @@ -24,8 +24,8 @@ var _isObject = require('./isObject'); * @param {*} val 待校验的参数 * @param {Object} options 可选参数 * @param {Boolean} options.isStrict 是否严格模式 - * @return {Boolean} 返回校验结果 - * @version 0.0.5 + * @return {Booean} 返回校验结果 + * @version 0.0.7 * @since 0.0.4 */ function _isUnEmptyString(val, options) { @@ -35,7 +35,15 @@ function _isUnEmptyString(val, options) { return false; } - return opts.isStrict === false ? val !== '' : (val.trim() !== ''); + if (opts.isStrict === false) { + return val !== ''; + } + + // @TODO + // 引用: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim + // String.prototype.trim, 在 ECMAScript 5.1 定义, 在 JavaScript 1.8.1 实现 + // return val.replace(REGEX_ENUM.LEFT_WHITE_SPACE_REX, '').replace(REGEX_ENUM.RIGHT_WHITE_SPACE_REX, '') !== ''; + return val.trim() !== ''; } module.exports = _isUnEmptyString; diff --git a/src/isUnNegativeNumber.js b/src/isUnNegativeNumber.js index 0fac399..96fa370 100644 --- a/src/isUnNegativeNumber.js +++ b/src/isUnNegativeNumber.js @@ -1,7 +1,6 @@ -var _isNumber = require('./isNumber'); -var _isObject = require('./isObject'); -var REGEX_ENUM = require('./internal/enum/regexEnum'); +var _isZero = require('./isZero'); +var _isPositiveNumber = require('./isPositiveNumber'); /** * 校验参数 `val` 是否为非负数, 即正数和零 @@ -28,17 +27,11 @@ var REGEX_ENUM = require('./internal/enum/regexEnum'); * @param {Object} options 可选参数 * @param {Boolean} options.isStrict 是否严格模式 * @return {Boolean} 返回校验结果 - * @version 0.0.5 + * @version 0.0.7 * @since 0.0.4 */ function _isUnNegativeNumber(val, options) { - var opts = _isObject(options) ? options : {}; - - if (opts.isStrict === true) { - return _isNumber(val) && REGEX_ENUM.UN_NEGATIVE_NUMBER_REX.test(val); - } - - return REGEX_ENUM.UN_NEGATIVE_NUMBER_REX.test(val); + return _isPositiveNumber(val, options) || _isZero(val, options); } module.exports = _isUnNegativeNumber; diff --git a/src/isUnPositiveNumber.js b/src/isUnPositiveNumber.js index d7accf8..b5ba7a0 100644 --- a/src/isUnPositiveNumber.js +++ b/src/isUnPositiveNumber.js @@ -1,7 +1,6 @@ -var _isNumber = require('./isNumber'); -var _isObject = require('./isObject'); -var REGEX_ENUM = require('./internal/enum/regexEnum'); +var _isZero = require('./isZero'); +var _isNegativeNumber = require('./isNegativeNumber'); /** * 校验参数 `val` 是否为非正数, 即负数和零 @@ -28,17 +27,11 @@ var REGEX_ENUM = require('./internal/enum/regexEnum'); * @param {Object} options 可选参数 * @param {Boolean} options.isStrict 是否严格模式 * @return {Boolean} 返回校验结果 - * @version 0.0.5 + * @version 0.0.7 * @since 0.0.4 */ function _isUnPositiveNumber(val, options) { - var opts = _isObject(options) ? options : {}; - - if (opts.isStrict === true) { - return _isNumber(val) && REGEX_ENUM.UN_POSITIVE_NUMBER_REX.test(val); - } - - return REGEX_ENUM.UN_POSITIVE_NUMBER_REX.test(val); + return _isNegativeNumber(val, options) || _isZero(val, options); } module.exports = _isUnPositiveNumber; diff --git a/src/isZero.js b/src/isZero.js index 51fe3e5..7dd4ac5 100644 --- a/src/isZero.js +++ b/src/isZero.js @@ -1,5 +1,6 @@ var _isObject = require('./isObject'); +var _isNumber = require('./isNumber'); var _isRealNumber = require('./isRealNumber'); /** @@ -27,17 +28,21 @@ var _isRealNumber = require('./isRealNumber'); * @param {Object} options 可选参数 * @param {Boolean} options.isStrict 是否严格模式 * @return {Boolean} 返回校验结果 - * @version 0.0.5 + * @version 0.0.7 * @since 0.0.4 */ function _isZero(val, options) { var opts = _isObject(options) ? options : {}; - if (opts.isStrict === true) { - return val === 0; + if (_isNumber(val)) { + return val - 0 === 0; } - return _isRealNumber(val) && val - 0 === 0; + if (opts.isStrict !== true) { + return _isRealNumber(val) && val - 0 === 0; + } + + return false; } module.exports = _isZero; diff --git a/test/isArray.test.js b/test/isArray.test.js index 28d8fc2..a31c94a 100644 --- a/test/isArray.test.js +++ b/test/isArray.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isArray test', function () { +describe('isArray', function () { // [] it(`isArray([]) === true`, function () { isArray([]).should.equal(true); @@ -42,9 +41,4 @@ describe('isArray test', function () { it(`isArray(Object([])) === true`, function () { isArray(Object([])).should.equal(true); }); - - // new Object([]) - it(`isArray(new Object([])) === true`, function () { - isArray(new Object([])).should.equal(true); - }); }); diff --git a/test/isBoolean.test.js b/test/isBoolean.test.js index 8ab905b..21b7920 100644 --- a/test/isBoolean.test.js +++ b/test/isBoolean.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isBoolean test', function () { +describe('isBoolean', function () { // true it(`isBoolean(true) === true`, function () { isBoolean(true).should.equal(true); @@ -38,16 +37,6 @@ describe('isBoolean test', function () { isBoolean('').should.equal(false); }); - // Boolean({}) - it(`isBoolean(Boolean({})) === true`, function () { - isBoolean(Boolean({})).should.equal(true); - }); - - // new Boolean({}) - it(`isBoolean(new Boolean({})) === true`, function () { - isBoolean(new Boolean({})).should.equal(true); - }); - // {} it(`isBoolean({}) === false`, function () { isBoolean({}).should.equal(false); @@ -57,4 +46,29 @@ describe('isBoolean test', function () { it(`isBoolean(Object(true)) === true`, function () { isBoolean(Object(true)).should.equal(true); }); + + // Object(false) + it(`isBoolean(Object(false)) === true`, function () { + isBoolean(Object(false)).should.equal(true); + }); + + // Object(null) + it(`isBoolean(Object(null)) === false`, function () { + isBoolean(Object(null)).should.equal(false); + }); + + // Object(undefined) + it(`isBoolean(Object(undefined)) === false`, function () { + isBoolean(Object(undefined)).should.equal(false); + }); + + // Object(0) + it(`isBoolean(Object(0)) === false`, function () { + isBoolean(Object(0)).should.equal(false); + }); + + // Object('') + it(`isBoolean(Object('')) === false`, function () { + isBoolean(Object('')).should.equal(false); + }); }); diff --git a/test/isEmail.test.js b/test/isEmail.test.js index c498e21..8982e46 100644 --- a/test/isEmail.test.js +++ b/test/isEmail.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isEmail test', function () { +describe('isEmail', function () { // '575099329@qq.com' it(`isEmail('575099329@qq.com') === true`, function () { isEmail('575099329@qq.com').should.equal(true); diff --git a/test/isEmptyArray.test.js b/test/isEmptyArray.test.js index 19e4f0e..9691ec0 100644 --- a/test/isEmptyArray.test.js +++ b/test/isEmptyArray.test.js @@ -6,23 +6,22 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isEmptyArray test', function () { +describe('isEmptyArray', function () { // [] it(`isEmptyArray([]) === true`, function () { isEmptyArray([]).should.equal(true); }); - // {} - it(`isEmptyArray({}) === false`, function () { - isEmptyArray({}).should.equal(false); - }); - // [1] it(`isEmptyArray([1]) === false`, function () { isEmptyArray([1]).should.equal(false); }); + // {} + it(`isEmptyArray({}) === false`, function () { + isEmptyArray({}).should.equal(false); + }); + // Object({}) it(`isEmptyArray(Object({})) === false`, function () { isEmptyArray(Object({})).should.equal(false); @@ -37,14 +36,4 @@ describe('isEmptyArray test', function () { it(`isEmptyArray(Object([1])) === false`, function () { isEmptyArray(Object([1])).should.equal(false); }); - - // new Object([]) - it(`isEmptyArray(new Object([])) === true`, function () { - isEmptyArray(new Object([])).should.equal(true); - }); - - // new Object([1]) - it(`isEmptyArray(new Object([1])) === false`, function () { - isEmptyArray(new Object([1])).should.equal(false); - }); }); diff --git a/test/isEmptyString.test.js b/test/isEmptyString.test.js index 5041d6e..96407f1 100644 --- a/test/isEmptyString.test.js +++ b/test/isEmptyString.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isEmptyString test', function () { +describe('isEmptyString', function () { // 3 it(`isEmptyString(3) === false`, function () { isEmptyString(3).should.equal(false); @@ -23,19 +22,19 @@ describe('isEmptyString test', function () { isEmptyString('').should.equal(true); }); + // ' ' + it(`isEmptyString(' ') === true`, function () { + isEmptyString(' ').should.equal(true); + }); + // '' it(`isEmptyString('', {isStrict: false}) === true`, function () { isEmptyString('', {isStrict: false}).should.equal(true); }); - // ' ' - it(`isEmptyString(' ') === true`, function () { - isEmptyString(' ').should.equal(true); - }); - - // ' ' - it(`isEmptyString(' ', {isStrict: false}) === false`, function () { - isEmptyString(' ', {isStrict: false}).should.equal(false); + // ' ' + it(`isEmptyString(' ', {isStrict: false}) === false`, function () { + isEmptyString(' ', {isStrict: false}).should.equal(false); }); // null diff --git a/test/isFunction.test.js b/test/isFunction.test.js index 7e7e6be..7966199 100644 --- a/test/isFunction.test.js +++ b/test/isFunction.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isFunction test', function () { +describe('isFunction', function () { // [] it(`isFunction([]) === false`, function () { isFunction([]).should.equal(false); diff --git a/test/isInfinity.test.js b/test/isInfinity.test.js index 7c309e3..137a15e 100644 --- a/test/isInfinity.test.js +++ b/test/isInfinity.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isInfinity test', function () { +describe('isInfinity', function () { // Infinity it(`isInfinity(Infinity) === true`, function () { isInfinity(Number.POSITIVE_INFINITY).should.equal(true); @@ -33,6 +32,11 @@ describe('isInfinity test', function () { isInfinity(undefined).should.equal(false); }); + // 0 + it(`isInfinity(0) === false`, function () { + isInfinity(0).should.equal(false); + }); + // 3 it(`isInfinity(3) === false`, function () { isInfinity(3).should.equal(false); diff --git a/test/isInteger.test.js b/test/isInteger.test.js index d117a38..6b7d4af 100644 --- a/test/isInteger.test.js +++ b/test/isInteger.test.js @@ -6,38 +6,132 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isInteger test', function () { +describe('isInteger', function () { + // .3 + it(`isInteger(.3) === false`, function () { + isInteger(.3).should.equal(false); + }); + // 3 it(`isInteger(3) === true`, function () { isInteger(3).should.equal(true); }); + // 3. + it(`isInteger(3.) === true`, function () { + isInteger(3.).should.equal(true); + }); + + // 3.3 + it(`isInteger(3.3) === false`, function () { + isInteger(3.3).should.equal(false); + }); + + // '.3' + it(`isInteger('.3') === false`, function () { + isInteger('.3').should.equal(false); + }); + // '3' it(`isInteger('3') === true`, function () { isInteger('3').should.equal(true); }); + // '3.' + it(`isInteger('3.') === false`, function () { + isInteger('3.').should.equal(false); + }); + + // '3.3' + it(`isInteger('3.3') === false`, function () { + isInteger('3.3 ').should.equal(false); + }); + + // .3 + it(`isInteger(.3, {isStrict: true}) === false`, function () { + isInteger(.3, {isStrict: true}).should.equal(false); + }); + // 3 it(`isInteger(3, {isStrict: true}) === true`, function () { isInteger(3, {isStrict: true}).should.equal(true); }); + // 3. + it(`isInteger(3., {isStrict: true}) === true`, function () { + isInteger(3., {isStrict: true}).should.equal(true); + }); + + // 3.3 + it(`isInteger(3.3, {isStrict: true}) === false`, function () { + isInteger(3.3, {isStrict: true}).should.equal(false); + }); + + // '.3' + it(`isInteger('.3', {isStrict: true}) === false`, function () { + isInteger('.3', {isStrict: true}).should.equal(false); + }); + // '3' it(`isInteger('3', {isStrict: true}) === false`, function () { isInteger('3', {isStrict: true}).should.equal(false); }); + // '3.' + it(`isInteger('3.', {isStrict: true}) === false`, function () { + isInteger('3.', {isStrict: true}).should.equal(false); + }); + + // '3.3' + it(`isInteger('3.3', {isStrict: true}) === false`, function () { + isInteger('3.3', {isStrict: true}).should.equal(false); + }); + // 0 it(`isInteger(0) === true`, function () { isInteger(0).should.equal(true); }); + // 0. + it(`isInteger(0.) === true`, function () { + isInteger(0.).should.equal(true); + }); + + // .0 + it(`isInteger(.0) === true`, function () { + isInteger(.0).should.equal(true); + }); + + // 0.0 + it(`isInteger(0.0) === true`, function () { + isInteger(0.0).should.equal(true); + }); + // '0' it(`isInteger('0') === true`, function () { isInteger('0').should.equal(true); }); + // '0.' + it(`isInteger('0.') === false`, function () { + isInteger('0.').should.equal(false); + }); + + // '.0' + it(`isInteger('.0') === false`, function () { + isInteger('.0').should.equal(false); + }); + + // '0.0' + it(`isInteger('0.0') === false`, function () { + isInteger('0.0').should.equal(false); + }); + + // '.' + it(`isInteger('.') === false`, function () { + isInteger('.').should.equal(false); + }); + // 0 it(`isInteger(0, {isStrict: true}) === true`, function () { isInteger(0, {isStrict: true}).should.equal(true); @@ -48,54 +142,69 @@ describe('isInteger test', function () { isInteger('0', {isStrict: true}).should.equal(false); }); + // -.3 + it(`isInteger(-.3) === false`, function () { + isInteger(-.3).should.equal(false); + }); + // -3 it(`isInteger(-3) === true`, function () { isInteger(-3).should.equal(true); }); - // '-3' - it(`isInteger('-3') === true`, function () { - isInteger('-3').should.equal(true); + // -3. + it(`isInteger(-3.) === true`, function () { + isInteger(-3.).should.equal(true); }); - // -3 - it(`isInteger(-3, {isStrict: true}) === true`, function () { - isInteger(-3, {isStrict: true}).should.equal(true); + // -3.3 + it(`isInteger(-3.3) === false`, function () { + isInteger(-3.3).should.equal(false); + }); + + // '-.3' + it(`isInteger('-.3') === false`, function () { + isInteger('-.3').should.equal(false); }); // '-3' - it(`isInteger('-3', {isStrict: true}) === false`, function () { - isInteger('-3', {isStrict: true}).should.equal(false); + it(`isInteger('-3') === true`, function () { + isInteger('-3').should.equal(true); }); - // 3.3 - it(`isInteger(3.3) === false`, function () { - isInteger(3.3).should.equal(false); + // '-3.' + it(`isInteger('-3.') === false`, function () { + isInteger('-3.').should.equal(false); }); - // '3.3' - it(`isInteger('3.3') === false`, function () { - isInteger('3.3').should.equal(false); + // '-3.3' + it(`isInteger('-3.3') === false`, function () { + isInteger('-3.3').should.equal(false); }); - // 3.3 - it(`isInteger(3.3, {isStrict: true}) === false`, function () { - isInteger(3.3, {isStrict: true}).should.equal(false); + // '--3' + it(`isInteger('--3') === false`, function () { + isInteger('--3').should.equal(false); }); - // '3.3' - it(`isInteger('3.3', {isStrict: true}) === false`, function () { - isInteger('3.3', {isStrict: true}).should.equal(false); + // '-3-3' + it(`isInteger('-3-3') === false`, function () { + isInteger('-3-3').should.equal(false); }); - // -3.3 - it(`isInteger(-3.3) === false`, function () { - isInteger(-3.3).should.equal(false); + // -.3 + it(`isInteger(-.3, {isStrict: true}) === false`, function () { + isInteger(-.3, {isStrict: true}).should.equal(false); }); - // '-3.3' - it(`isInteger('-3.3') === false`, function () { - isInteger('-3.3').should.equal(false); + // -3 + it(`isInteger(-3, {isStrict: true}) === true`, function () { + isInteger(-3, {isStrict: true}).should.equal(true); + }); + + // -3. + it(`isInteger(-3., {isStrict: true}) === true`, function () { + isInteger(-3., {isStrict: true}).should.equal(true); }); // -3.3 @@ -103,19 +212,24 @@ describe('isInteger test', function () { isInteger(-3.3, {isStrict: true}).should.equal(false); }); - // '-3.3' - it(`isInteger('-3.3', {isStrict: true}) === false`, function () { - isInteger('-3.3', {isStrict: true}).should.equal(false); + // '-.3' + it(`isInteger('-.3', {isStrict: true}) === false`, function () { + isInteger('-.3', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isInteger(Number.POSITIVE_INFINITY) === false`, function () { - isInteger(Number.POSITIVE_INFINITY).should.equal(false); + // '-3' + it(`isInteger('-3', {isStrict: true}) === false`, function () { + isInteger('-3', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isInteger(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function () { - isInteger(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + // '-3.' + it(`isInteger('-3.', {isStrict: true}) === false`, function () { + isInteger('-3.', {isStrict: true}).should.equal(false); + }); + + // '-3.3' + it(`isInteger('-3.3', {isStrict: true}) === false`, function () { + isInteger('-3.3', {isStrict: true}).should.equal(false); }); // '' @@ -152,4 +266,44 @@ describe('isInteger test', function () { it(`isInteger(-Infinity) === false`, function () { isInteger(Number.NEGATIVE_INFINITY).should.equal(false); }); + + // Object(3) + it(`isInteger(Object(3)) === true`, function () { + isInteger(Object(3)).should.equal(true); + }); + + // Object('3') + it(`isInteger(Object('3')) === true`, function () { + isInteger(Object('3')).should.equal(true); + }); + + // Object(3) + it(`isInteger(Object(3), {isStrict: true}) === true`, function () { + isInteger(Object(3), {isStrict: true}).should.equal(true); + }); + + // Object('3') + it(`isInteger(Object('3'), {isStrict: true}) === false`, function () { + isInteger(Object('3'), {isStrict: true}).should.equal(false); + }); + + // Object(-3) + it(`isInteger(Object(-3)) === true`, function () { + isInteger(Object(-3)).should.equal(true); + }); + + // Object('-3') + it(`isInteger(Object('-3')) === true`, function () { + isInteger(Object('-3')).should.equal(true); + }); + + // Object(-3) + it(`isInteger(Object(-3), {isStrict: true}) === true`, function () { + isInteger(Object(-3), {isStrict: true}).should.equal(true); + }); + + // Object('-3') + it(`isInteger(Object('-3'), {isStrict: true}) === false`, function () { + isInteger(Object('-3'), {isStrict: true}).should.equal(false); + }); }); diff --git a/test/isIpv4.test.js b/test/isIpv4.test.js index 83aa2a0..fa914f6 100644 --- a/test/isIpv4.test.js +++ b/test/isIpv4.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isIpv4 test', function () { +describe('isIpv4', function () { // '192.168.1.1' it(`isIpv4('192.168.1.1') === true`, function () { isIpv4('192.168.1.1').should.equal(true); diff --git a/test/isJSON.test.js b/test/isJSON.test.js index 0638eb8..ca98af4 100644 --- a/test/isJSON.test.js +++ b/test/isJSON.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isJSON test', function () { +describe('isJSON', function () { // '{"a": 3}' it(`isJSON('{"a": 3}') === true`, function () { isJSON('{"a": 3}').should.equal(true); diff --git a/test/isMobile.test.js b/test/isMobile.test.js index c9eafda..1ad4e2d 100644 --- a/test/isMobile.test.js +++ b/test/isMobile.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isMobile test', function () { +describe('isMobile', function () { // '18505505933' it(`isMobile('18505505933') === true`, function () { isMobile('18505505933').should.equal(true); diff --git a/test/isNaN.test.js b/test/isNaN.test.js index 17563e6..64291fe 100644 --- a/test/isNaN.test.js +++ b/test/isNaN.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isNaN test', function () { +describe('isNaN', function () { // NaN it(`isNaN(NaN) === true`, function () { _isNaN(NaN).should.equal(true); diff --git a/test/isNegativeInteger.test.js b/test/isNegativeInteger.test.js index 10a408e..caa5247 100644 --- a/test/isNegativeInteger.test.js +++ b/test/isNegativeInteger.test.js @@ -6,38 +6,132 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isNegativeInteger test', function () { +describe('isNegativeInteger', function () { + // .3 + it(`isNegativeInteger(.3) === false`, function () { + isNegativeInteger(.3).should.equal(false); + }); + // 3 it(`isNegativeInteger(3) === false`, function () { isNegativeInteger(3).should.equal(false); }); + // 3. + it(`isNegativeInteger(3.) === false`, function () { + isNegativeInteger(3.).should.equal(false); + }); + + // 3.3 + it(`isNegativeInteger(3.3) === false`, function () { + isNegativeInteger(3.3).should.equal(false); + }); + + // '.3' + it(`isNegativeInteger('.3') === false`, function () { + isNegativeInteger('.3').should.equal(false); + }); + // '3' it(`isNegativeInteger('3') === false`, function () { isNegativeInteger('3').should.equal(false); }); + // '3.' + it(`isNegativeInteger('3.') === false`, function () { + isNegativeInteger('3.').should.equal(false); + }); + + // '3.3' + it(`isNegativeInteger('3.3') === false`, function () { + isNegativeInteger('3.3 ').should.equal(false); + }); + + // .3 + it(`isNegativeInteger(.3, {isStrict: true}) === false`, function () { + isNegativeInteger(.3, {isStrict: true}).should.equal(false); + }); + // 3 it(`isNegativeInteger(3, {isStrict: true}) === false`, function () { isNegativeInteger(3, {isStrict: true}).should.equal(false); }); + // 3. + it(`isNegativeInteger(3., {isStrict: true}) === false`, function () { + isNegativeInteger(3., {isStrict: true}).should.equal(false); + }); + + // 3.3 + it(`isNegativeInteger(3.3, {isStrict: true}) === false`, function () { + isNegativeInteger(3.3, {isStrict: true}).should.equal(false); + }); + + // '.3' + it(`isNegativeInteger('.3', {isStrict: true}) === false`, function () { + isNegativeInteger('.3', {isStrict: true}).should.equal(false); + }); + // '3' it(`isNegativeInteger('3', {isStrict: true}) === false`, function () { isNegativeInteger('3', {isStrict: true}).should.equal(false); }); + // '3.' + it(`isNegativeInteger('3.', {isStrict: true}) === false`, function () { + isNegativeInteger('3.', {isStrict: true}).should.equal(false); + }); + + // '3.3' + it(`isNegativeInteger('3.3', {isStrict: true}) === false`, function () { + isNegativeInteger('3.3', {isStrict: true}).should.equal(false); + }); + // 0 it(`isNegativeInteger(0) === false`, function () { isNegativeInteger(0).should.equal(false); }); + // 0. + it(`isNegativeInteger(0.) === false`, function () { + isNegativeInteger(0.).should.equal(false); + }); + + // .0 + it(`isNegativeInteger(.0) === false`, function () { + isNegativeInteger(.0).should.equal(false); + }); + + // 0.0 + it(`isNegativeInteger(0.0) === false`, function () { + isNegativeInteger(0.0).should.equal(false); + }); + // '0' it(`isNegativeInteger('0') === false`, function () { isNegativeInteger('0').should.equal(false); }); + // '0.' + it(`isNegativeInteger('0.') === false`, function () { + isNegativeInteger('0.').should.equal(false); + }); + + // '.0' + it(`isNegativeInteger('.0') === false`, function () { + isNegativeInteger('.0').should.equal(false); + }); + + // '0.0' + it(`isNegativeInteger('0.0') === false`, function () { + isNegativeInteger('0.0').should.equal(false); + }); + + // '.' + it(`isNegativeInteger('.') === false`, function () { + isNegativeInteger('.').should.equal(false); + }); + // 0 it(`isNegativeInteger(0, {isStrict: true}) === false`, function () { isNegativeInteger(0, {isStrict: true}).should.equal(false); @@ -48,54 +142,69 @@ describe('isNegativeInteger test', function () { isNegativeInteger('0', {isStrict: true}).should.equal(false); }); + // -.3 + it(`isNegativeInteger(-.3) === false`, function () { + isNegativeInteger(-.3).should.equal(false); + }); + // -3 it(`isNegativeInteger(-3) === true`, function () { isNegativeInteger(-3).should.equal(true); }); - // '-3' - it(`isNegativeInteger('-3') === true`, function () { - isNegativeInteger('-3').should.equal(true); + // -3. + it(`isNegativeInteger(-3.) === true`, function () { + isNegativeInteger(-3.).should.equal(true); }); - // -3 - it(`isNegativeInteger(-3, {isStrict: true}) === false`, function () { - isNegativeInteger(-3, {isStrict: true}).should.equal(true); + // -3.3 + it(`isNegativeInteger(-3.3) === false`, function () { + isNegativeInteger(-3.3).should.equal(false); + }); + + // '-.3' + it(`isNegativeInteger('-.3') === false`, function () { + isNegativeInteger('-.3').should.equal(false); }); // '-3' - it(`isNegativeInteger('-3', {isStrict: true}) === false`, function () { - isNegativeInteger('-3', {isStrict: true}).should.equal(false); + it(`isNegativeInteger('-3') === true`, function () { + isNegativeInteger('-3').should.equal(true); }); - // 3.3 - it(`isNegativeInteger(3.3) === false`, function () { - isNegativeInteger(3.3).should.equal(false); + // '-3.' + it(`isNegativeInteger('-3.') === false`, function () { + isNegativeInteger('-3.').should.equal(false); }); - // '3.3' - it(`isNegativeInteger('3.3') === false`, function () { - isNegativeInteger('3.3').should.equal(false); + // '-3.3' + it(`isNegativeInteger('-3.3') === false`, function () { + isNegativeInteger('-3.3').should.equal(false); }); - // 3.3 - it(`isNegativeInteger(3.3, {isStrict: true}) === false`, function () { - isNegativeInteger(3.3, {isStrict: true}).should.equal(false); + // '--3' + it(`isNegativeInteger('--3') === false`, function () { + isNegativeInteger('--3').should.equal(false); }); - // '3.3' - it(`isNegativeInteger('3.3', {isStrict: true}) === false`, function () { - isNegativeInteger('3.3', {isStrict: true}).should.equal(false); + // '-3-3' + it(`isNegativeInteger('-3-3') === false`, function () { + isNegativeInteger('-3-3').should.equal(false); }); - // -3.3 - it(`isNegativeInteger(-3.3) === false`, function () { - isNegativeInteger(-3.3).should.equal(false); + // -.3 + it(`isNegativeInteger(-.3, {isStrict: true}) === false`, function () { + isNegativeInteger(-.3, {isStrict: true}).should.equal(false); }); - // '-3.3' - it(`isNegativeInteger('-3.3') === false`, function () { - isNegativeInteger('-3.3').should.equal(false); + // -3 + it(`isNegativeInteger(-3, {isStrict: true}) === true`, function () { + isNegativeInteger(-3, {isStrict: true}).should.equal(true); + }); + + // -3. + it(`isNegativeInteger(-3., {isStrict: true}) === true`, function () { + isNegativeInteger(-3., {isStrict: true}).should.equal(true); }); // -3.3 @@ -103,19 +212,24 @@ describe('isNegativeInteger test', function () { isNegativeInteger(-3.3, {isStrict: true}).should.equal(false); }); - // '-3.3' - it(`isNegativeInteger('-3.3', {isStrict: true}) === false`, function () { - isNegativeInteger('-3.3', {isStrict: true}).should.equal(false); + // '-.3' + it(`isNegativeInteger('-.3', {isStrict: true}) === false`, function () { + isNegativeInteger('-.3', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isNegativeInteger(Number.POSITIVE_INFINITY) === false`, function () { - isNegativeInteger(Number.POSITIVE_INFINITY).should.equal(false); + // '-3' + it(`isNegativeInteger('-3', {isStrict: true}) === false`, function () { + isNegativeInteger('-3', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isNegativeInteger(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function () { - isNegativeInteger(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + // '-3.' + it(`isNegativeInteger('-3.', {isStrict: true}) === false`, function () { + isNegativeInteger('-3.', {isStrict: true}).should.equal(false); + }); + + // '-3.3' + it(`isNegativeInteger('-3.3', {isStrict: true}) === false`, function () { + isNegativeInteger('-3.3', {isStrict: true}).should.equal(false); }); // '' @@ -152,4 +266,44 @@ describe('isNegativeInteger test', function () { it(`isNegativeInteger(-Infinity) === false`, function () { isNegativeInteger(Number.NEGATIVE_INFINITY).should.equal(false); }); + + // Object(3) + it(`isNegativeInteger(Object(3)) === false`, function () { + isNegativeInteger(Object(3)).should.equal(false); + }); + + // Object('3') + it(`isNegativeInteger(Object('3')) === false`, function () { + isNegativeInteger(Object('3')).should.equal(false); + }); + + // Object(3) + it(`isNegativeInteger(Object(3), {isStrict: true}) === false`, function () { + isNegativeInteger(Object(3), {isStrict: true}).should.equal(false); + }); + + // Object('3') + it(`isNegativeInteger(Object('3'), {isStrict: true}) === false`, function () { + isNegativeInteger(Object('3'), {isStrict: true}).should.equal(false); + }); + + // Object(-3) + it(`isNegativeInteger(Object(-3)) === true`, function () { + isNegativeInteger(Object(-3)).should.equal(true); + }); + + // Object('-3') + it(`isNegativeInteger(Object('-3')) === true`, function () { + isNegativeInteger(Object('-3')).should.equal(true); + }); + + // Object(-3) + it(`isNegativeInteger(Object(-3), {isStrict: true}) === true`, function () { + isNegativeInteger(Object(-3), {isStrict: true}).should.equal(true); + }); + + // Object('-3') + it(`isNegativeInteger(Object('-3'), {isStrict: true}) === false`, function () { + isNegativeInteger(Object('-3'), {isStrict: true}).should.equal(false); + }); }); diff --git a/test/isNegativeNumber.test.js b/test/isNegativeNumber.test.js index 12956ab..fedcf8f 100644 --- a/test/isNegativeNumber.test.js +++ b/test/isNegativeNumber.test.js @@ -6,38 +6,267 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isNegativeNumber test', function () { +describe('isNegativeNumber', function () { + // -.3 + it(`isNegativeNumber(-.3) === true`, function () { + isNegativeNumber(-.3).should.equal(true); + }); + + // -0.3 + it(`isNegativeNumber(-0.3) === true`, function () { + isNegativeNumber(-0.3).should.equal(true); + }); + + // -0.35 + it(`isNegativeNumber(-0.35) === true`, function () { + isNegativeNumber(-0.35).should.equal(true); + }); + + // -0.356 + it(`isNegativeNumber(-0.356) === true`, function () { + isNegativeNumber(-0.356).should.equal(true); + }); + + // '-.3' + it(`isNegativeNumber('-.3') === true`, function () { + isNegativeNumber('-.3').should.equal(true); + }); + + // '-0.3' + it(`isPositiveNumber('-0.3') === true`, function () { + isNegativeNumber('-0.3').should.equal(true); + }); + + // '-0.35' + it(`isNegativeNumber('-0.35') === true`, function () { + isNegativeNumber('-0.35').should.equal(true); + }); + + // '-0.356' + it(`isNegativeNumber('-0.356') === true`, function () { + isNegativeNumber('-0.356').should.equal(true); + }); + + // '-00.356' + it(`isNegativeNumber('-00.356') === false`, function () { + isNegativeNumber('-00.356').should.equal(false); + }); + + // '-0.3.56' + it(`isNegativeNumber('-0.3.56') === false`, function () { + isNegativeNumber('-0.3.56').should.equal(false); + }); + + // '-0.356.' + it(`isNegativeNumber('-0.356.') === false`, function () { + isNegativeNumber('-0.356.').should.equal(false); + }); + + // -.3 + it(`isNegativeNumber(-.3, {isStrict: true}) === true`, function () { + isNegativeNumber(-.3, {isStrict: true}).should.equal(true); + }); + + // -0.3 + it(`isNegativeNumber(-0.3, {isStrict: true}) === true`, function () { + isNegativeNumber(-0.3, {isStrict: true}).should.equal(true); + }); + + // -0.35 + it(`isNegativeNumber(-0.35, {isStrict: true}) === true`, function () { + isNegativeNumber(-0.35, {isStrict: true}).should.equal(true); + }); + + // -0.356 + it(`isNegativeNumber(-0.356, {isStrict: true}) === true`, function () { + isNegativeNumber(-0.356, {isStrict: true}).should.equal(true); + }); + + // '-.3' + it(`isNegativeNumber('-.3', {isStrict: true}) === false`, function () { + isNegativeNumber('-.3', {isStrict: true}).should.equal(false); + }); + + // '-0.3' + it(`isNegativeNumber('-0.3', {isStrict: true}) === false`, function () { + isNegativeNumber('-0.3', {isStrict: true}).should.equal(false); + }); + + // '-0.35' + it(`isNegativeNumber('-0.35', {isStrict: true}) === false`, function () { + isNegativeNumber('-0.35', {isStrict: true}).should.equal(false); + }); + + // '-0.356' + it(`isNegativeNumber('-0.356', {isStrict: true}) === false`, function () { + isNegativeNumber('-0.356', {isStrict: true}).should.equal(false); + }); + // -3 it(`isNegativeNumber(-3) === true`, function () { isNegativeNumber(-3).should.equal(true); }); + // -3.5 + it(`isNegativeNumber(-3.5) === true`, function () { + isNegativeNumber(-3.5).should.equal(true); + }); + + // -3.56 + it(`isNegativeNumber(-3.56) === true`, function () { + isNegativeNumber(-3.56).should.equal(true); + }); + + // -30.56 + it(`isNegativeNumber(-30.56) === true`, function () { + isNegativeNumber(-30.56).should.equal(true); + }); + + // -30. + it(`isNegativeNumber(-30.) === true`, function () { + isNegativeNumber(-30.).should.equal(true); + }); + // '-3' it(`isNegativeNumber('-3') === true`, function () { isNegativeNumber('-3').should.equal(true); }); + // '-3.5' + it(`isNegativeNumber('-3.5') === true`, function () { + isNegativeNumber('-3.5').should.equal(true); + }); + + // '-3.56' + it(`isNegativeNumber('-3.56') === true`, function () { + isNegativeNumber('-3.56').should.equal(true); + }); + + // '-30.56' + it(`isNegativeNumber('-30.56') === true`, function () { + isNegativeNumber('-30.56').should.equal(true); + }); + + // '-30.' + it(`isNegativeNumber('-30.') === true`, function () { + isNegativeNumber('-30.').should.equal(true); + }); + + // '-30.5.6' + it(`isNegativeNumber('-30.5.6') === false`, function () { + isNegativeNumber('-30.5.6').should.equal(false); + }); + + // '-30.56.' + it(`isNegativeNumber('-30.56.') === false`, function () { + isNegativeNumber('-30.56.').should.equal(false); + }); + // -3 it(`isNegativeNumber(-3, {isStrict: true}) === true`, function () { isNegativeNumber(-3, {isStrict: true}).should.equal(true); }); + // -3.5 + it(`isNegativeNumber(-3.5, {isStrict: true}) === true`, function () { + isNegativeNumber(-3.5, {isStrict: true}).should.equal(true); + }); + + // -3.56 + it(`isNegativeNumber(-3.56, {isStrict: true}) === true`, function () { + isNegativeNumber(-3.56, {isStrict: true}).should.equal(true); + }); + + // -30.56 + it(`isNegativeNumber(-30.56, {isStrict: true}) === true`, function () { + isNegativeNumber(-30.56, {isStrict: true}).should.equal(true); + }); + + // -30. + it(`isNegativeNumber(-30., {isStrict: true}) === true`, function () { + isNegativeNumber(-30., {isStrict: true}).should.equal(true); + }); + // '-3' it(`isNegativeNumber('-3', {isStrict: true}) === false`, function () { isNegativeNumber('-3', {isStrict: true}).should.equal(false); }); + // '-3.5' + it(`isNegativeNumber('-3.5', {isStrict: true}) === false`, function () { + isNegativeNumber('-3.5', {isStrict: true}).should.equal(false); + }); + + // '-3.56' + it(`isNegativeNumber('-3.56', {isStrict: true}) === false`, function () { + isNegativeNumber('-3.56', {isStrict: true}).should.equal(false); + }); + + // '-30.56' + it(`isNegativeNumber('-30.56', {isStrict: true}) === false`, function () { + isNegativeNumber('-30.56', {isStrict: true}).should.equal(false); + }); + + // '-30.' + it(`isNegativeNumber('-30.', {isStrict: true}) === false`, function () { + isNegativeNumber('-30.', {isStrict: true}).should.equal(false); + }); + // 0 it(`isNegativeNumber(0) === false`, function () { isNegativeNumber(0).should.equal(false); }); + // +0 + it(`isNegativeNumber(+0) === false`, function () { + isNegativeNumber(+0).should.equal(false); + }); + + // -0 + it(`isNegativeNumber(-0) === false`, function () { + isNegativeNumber(-0).should.equal(false); + }); + + // 0. + it(`isNegativeNumber(0.) === false`, function () { + isNegativeNumber(0.).should.equal(false); + }); + + // .0 + it(`isNegativeNumber(.0) === false`, function () { + isNegativeNumber(.0).should.equal(false); + }); + // '0' it(`isNegativeNumber('0') === false`, function () { isNegativeNumber('0').should.equal(false); }); + // '+0' + it(`isNegativeNumber('+0') === false`, function () { + isNegativeNumber('+0').should.equal(false); + }); + + // '-0' + it(`isNegativeNumber('-0') === false`, function () { + isNegativeNumber('-0').should.equal(false); + }); + + // '0.' + it(`isNegativeNumber('0.') === false`, function () { + isNegativeNumber('0.').should.equal(false); + }); + + // '.' + it(`isNegativeNumber('.') === false`, function () { + isNegativeNumber('.').should.equal(false); + }); + + // '.0' + it(`isNegativeNumber('.0') === false`, function () { + isNegativeNumber('.0').should.equal(false); + }); + // 0 it(`isNegativeNumber(0, {isStrict: true}) === false`, function () { isNegativeNumber(0, {isStrict: true}).should.equal(false); @@ -48,19 +277,159 @@ describe('isNegativeNumber test', function () { isNegativeNumber('0', {isStrict: true}).should.equal(false); }); + // .3 + it(`isNegativeNumber(.3) === false`, function () { + isNegativeNumber(.3).should.equal(false); + }); + + // 0.3 + it(`isNegativeNumber(0.3) === false`, function () { + isNegativeNumber(0.3).should.equal(false); + }); + + // 0.35 + it(`isNegativeNumber(0.35) === false`, function () { + isNegativeNumber(0.35).should.equal(false); + }); + + // 0.356 + it(`isNegativeNumber(0.356) === false`, function () { + isNegativeNumber(0.356).should.equal(false); + }); + + // '.3' + it(`isNegativeNumber('.3') === false`, function () { + isNegativeNumber('.3').should.equal(false); + }); + + // '0.3' + it(`isNegativeNumber('0.3') === false`, function () { + isNegativeNumber('0.3').should.equal(false); + }); + + // '0.35' + it(`isNegativeNumber('0.35') === false`, function () { + isNegativeNumber('0.35').should.equal(false); + }); + + // '0.356' + it(`isNegativeNumber('0.356') === false`, function () { + isNegativeNumber('0.356').should.equal(false); + }); + + // .3 + it(`isNegativeNumber(.3, {isStrict: true}) === false`, function () { + isNegativeNumber(.3, {isStrict: true}).should.equal(false); + }); + + // 0.3 + it(`isNegativeNumber(0.3, {isStrict: true}) === false`, function () { + isNegativeNumber(0.3, {isStrict: true}).should.equal(false); + }); + + // 0.35 + it(`isNegativeNumber(0.35, {isStrict: true}) === false`, function () { + isNegativeNumber(0.35, {isStrict: true}).should.equal(false); + }); + + // 0.356 + it(`isNegativeNumber(0.356, {isStrict: true}) === false`, function () { + isNegativeNumber(0.356, {isStrict: true}).should.equal(false); + }); + + // '.3' + it(`isNegativeNumber('.3', {isStrict: true}) === false`, function () { + isNegativeNumber('.3', {isStrict: true}).should.equal(false); + }); + + // '0.3' + it(`isNegativeNumber('0.3', {isStrict: true}) === false`, function () { + isNegativeNumber('0.3', {isStrict: true}).should.equal(false); + }); + + // '0.35' + it(`isNegativeNumber('0.35', {isStrict: true}) === false`, function () { + isNegativeNumber('0.35', {isStrict: true}).should.equal(false); + }); + + // '0.356' + it(`isNegativeNumber('0.356', {isStrict: true}) === false`, function () { + isNegativeNumber('0.356', {isStrict: true}).should.equal(false); + }); + // 3 it(`isNegativeNumber(3) === false`, function () { isNegativeNumber(3).should.equal(false); }); + // 3.5 + it(`isNegativeNumber(3.5) === false`, function () { + isNegativeNumber(3.5).should.equal(false); + }); + + // 3.56 + it(`isNegativeNumber(3.56) === false`, function () { + isNegativeNumber(3.56).should.equal(false); + }); + + // 30.56 + it(`isNegativeNumber(30.56) === false`, function () { + isNegativeNumber(30.56).should.equal(false); + }); + + // 30. + it(`isNegativeNumber(30.) === false`, function () { + isNegativeNumber(30.).should.equal(false); + }); + // '3' it(`isNegativeNumber('3') === false`, function () { isNegativeNumber('3').should.equal(false); }); + // '3.5' + it(`isNegativeNumber('3.5') === false`, function () { + isNegativeNumber('3.5').should.equal(false); + }); + + // '3.56' + it(`isNegativeNumber('3.56') === false`, function () { + isNegativeNumber('3.56').should.equal(false); + }); + + // '30.56' + it(`v('30.56') === false`, function () { + isNegativeNumber('30.56').should.equal(false); + }); + + // '30.' + it(`isNegativeNumber('30.') === false`, function () { + isNegativeNumber('30.').should.equal(false); + }); + // 3 it(`isNegativeNumber(3, {isStrict: true}) === false`, function () { - isNegativeNumber(3, {isStrict: false}).should.equal(false); + isNegativeNumber(3, {isStrict: true}).should.equal(false); + }); + + // 3.5 + it(`isNegativeNumber(3.5, {isStrict: true}) === false`, function () { + isNegativeNumber(3.5, {isStrict: true}).should.equal(false); + }); + + // 3.56 + it(`isNegativeNumber(3.56, {isStrict: true}) === false`, function () { + isNegativeNumber(3.56, {isStrict: true}).should.equal(false); + }); + + // 30.56 + it(`isNegativeNumber(30.56, {isStrict: true}) === false`, function () { + isNegativeNumber(30.56, {isStrict: true}).should.equal(false); + }); + + // 30. + it(`isNegativeNumber(30., {isStrict: true}) === false`, function () { + isNegativeNumber(30., {isStrict: true}).should.equal(false); }); // '3' @@ -68,14 +437,24 @@ describe('isNegativeNumber test', function () { isNegativeNumber('3', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isNegativeNumber(Number.POSITIVE_INFINITY) === false`, function () { - isNegativeNumber(Number.POSITIVE_INFINITY).should.equal(false); + // '3.5' + it(`isNegativeNumber('3.5', {isStrict: true}) === false`, function () { + isNegativeNumber('3.5', {isStrict: true}).should.equal(false); + }); + + // '3.56' + it(`isNegativeNumber('3.56', {isStrict: true}) === false`, function () { + isNegativeNumber('3.56', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isNegativeNumber(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function () { - isNegativeNumber(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + // '30.56' + it(`isNegativeNumber('30.56', {isStrict: true}) === false`, function () { + isNegativeNumber('30.56', {isStrict: true}).should.equal(false); + }); + + // '30.' + it(`isNegativeNumber('30.', {isStrict: true}) === false`, function () { + isNegativeNumber('30.', {isStrict: true}).should.equal(false); }); // '' @@ -112,4 +491,24 @@ describe('isNegativeNumber test', function () { it(`isNegativeNumber(-Infinity) === false`, function () { isNegativeNumber(Number.NEGATIVE_INFINITY).should.equal(false); }); + + // Object(-3.56) + it(`isNegativeNumber(Object(-3.56)) === true`, function () { + isNegativeNumber(Object(-3.56)).should.equal(true); + }); + + // Object('-3.56') + it(`isNegativeNumber(Object('-3.56')) === true`, function () { + isNegativeNumber(Object('-3.56')).should.equal(true); + }); + + // Object(-3.56) + it(`isNegativeNumber(Object(-3.56), {isStrict: true}) === true`, function () { + isNegativeNumber(Object(-3.56), {isStrict: true}).should.equal(true); + }); + + // Object('-3.56') + it(`isNegativeNumber(Object('-3.56'), {isStrict: true}) === false`, function () { + isNegativeNumber(Object('-3.56'), {isStrict: true}).should.equal(false); + }); }); diff --git a/test/isNil.test.js b/test/isNil.test.js index 9908b8a..a3f0e70 100644 --- a/test/isNil.test.js +++ b/test/isNil.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isNil test', function () { +describe('isNil', function () { // null it(`isNil(null) === true`, function () { isNil(null).should.equal(true); diff --git a/test/isNull.test.js b/test/isNull.test.js index f84b557..aa9d51c 100644 --- a/test/isNull.test.js +++ b/test/isNull.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isNull test', function () { +describe('isNull', function () { // null it(`isNull(null) === true`, function () { isNull(null).should.equal(true); diff --git a/test/isNumber.test.js b/test/isNumber.test.js index dc1feff..3635137 100644 --- a/test/isNumber.test.js +++ b/test/isNumber.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isNumber test', function () { +describe('isNumber', function () { // 3 it(`isNumber(3) === true`, function () { isNumber(3).should.equal(true); @@ -33,6 +32,16 @@ describe('isNumber test', function () { isNumber(Number.NEGATIVE_INFINITY).should.equal(true); }); + // MAX_SAFE_INTEGER + it(`isNumber(Number.MAX_SAFE_INTEGER) === true`, function () { + isNumber(Number.MAX_SAFE_INTEGER).should.equal(true); + }); + + // MIN_SAFE_INTEGER + it(`isNumber(Number.MIN_SAFE_INTEGER) === true`, function () { + isNumber(Number.MIN_SAFE_INTEGER).should.equal(true); + }); + // '' it(`isNumber('') === false`, function () { isNumber('').should.equal(false); @@ -43,6 +52,11 @@ describe('isNumber test', function () { isNumber(true).should.equal(false); }); + // false + it(`isNumber(false) === false`, function () { + isNumber(false).should.equal(false); + }); + // null it(`isNumber(null) === false`, function () { isNumber(null).should.equal(false); @@ -53,16 +67,6 @@ describe('isNumber test', function () { isNumber(undefined).should.equal(false); }); - // Number(3) - it(`isNumber(Number(3)) === true`, function () { - isNumber(Number(3)).should.equal(true); - }); - - // new Number(3) - it(`isNumber(new Number(3)) === true`, function () { - isNumber(new Number(3)).should.equal(true); - }); - // {} it(`isNumber({}) === false`, function () { isNumber({}).should.equal(false); @@ -77,4 +81,29 @@ describe('isNumber test', function () { it(`isNumber(Object('3')) === false`, function () { isNumber(Object('3')).should.equal(false); }); + + // Object('') + it(`isNumber(Object('')) === false`, function () { + isNumber(Object('')).should.equal(false); + }); + + // Object(true) + it(`isNumber(Object(true)) === false`, function () { + isNumber(Object(true)).should.equal(false); + }); + + // Object(false) + it(`isNumber(Object(false)) === false`, function () { + isNumber(Object(false)).should.equal(false); + }); + + // Object(null) + it(`isNumber(Object(null)) === false`, function () { + isNumber(Object(null)).should.equal(false); + }); + + // Object(undefined) + it(`isNumber(Object(undefined)) === false`, function () { + isNumber(Object(undefined)).should.equal(false); + }); }); diff --git a/test/isNumeric.test.js b/test/isNumeric.test.js index 25b6b16..d2e6434 100644 --- a/test/isNumeric.test.js +++ b/test/isNumeric.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isNumeric test', function () { +describe('isNumeric', function () { // 3 it(`isNumeric(3) === true`, function () { isNumeric(3).should.equal(true); @@ -33,6 +32,11 @@ describe('isNumeric test', function () { isNumeric('3a').should.equal(false); }); + // '3a' + it(`isNumeric('3a', {isStrict: true}) === false`, function () { + isNumeric('3a', {isStrict: true}).should.equal(false); + }); + // NaN it(`isNumeric(NaN) === false`, function () { isNumeric(NaN).should.equal(false); @@ -48,6 +52,16 @@ describe('isNumeric test', function () { isNumeric(Number.NEGATIVE_INFINITY).should.equal(false); }); + // MAX_SAFE_INTEGER + it(`isNumeric(Number.MAX_SAFE_INTEGER) === true`, function () { + isNumeric(Number.MAX_SAFE_INTEGER).should.equal(true); + }); + + // MIN_SAFE_INTEGER + it(`isNumeric(Number.MIN_SAFE_INTEGER) === true`, function () { + isNumeric(Number.MIN_SAFE_INTEGER).should.equal(true); + }); + // '' it(`isNumeric('') === false`, function () { isNumeric('').should.equal(false); @@ -68,16 +82,6 @@ describe('isNumeric test', function () { isNumeric(undefined).should.equal(false); }); - // Number(3) - it(`isNumeric(Number(3)) === true`, function () { - isNumeric(Number(3)).should.to.be.equal(true); - }); - - // new Number(3) - it(`isNumeric(new Number(3)) === true`, function () { - isNumeric(new Number(3)).should.equal(true); - }); - // {} it(`isNumeric({}) === false`, function () { isNumeric({}).should.equal(false); @@ -93,6 +97,11 @@ describe('isNumeric test', function () { isNumeric(Object('3')).should.equal(true); }); + // Object(3) + it(`isNumeric(Object(3), {isStrict: true}) === true`, function () { + isNumeric(Object(3), {isStrict: true}).should.equal(true); + }); + // Object('3') it(`isNumeric(Object('3'), {isStrict: true}) === false`, function () { isNumeric(Object('3'), {isStrict: true}).should.equal(false); diff --git a/test/isObject.test.js b/test/isObject.test.js index 102a7d3..a98b9a4 100644 --- a/test/isObject.test.js +++ b/test/isObject.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isObject test', function () { +describe('isObject', function () { // {} it(`isObject({}) === true`, function () { isObject({}).should.equal(true); @@ -28,19 +27,19 @@ describe('isObject test', function () { isObject(new Date()).should.equal(false); }); - // Object({}) - it(`isObject(Object({})) === true`, function () { - isObject(Object({})).should.equal(true); - }); - // Object('3') it(`isObject(Object('3')) === false`, function () { isObject(Object('3')).should.equal(false); }); - // new Object('3') - it(`isObject(new Object('3')) === false`, function () { - isObject(new Object('3')).should.equal(false); + // Object([]) + it(`isObject(Object([])) === false`, function () { + isObject(Object([])).should.equal(false); + }); + + // Object({}) + it(`isObject(Object({})) === true`, function () { + isObject(Object({})).should.equal(true); }); // null @@ -54,7 +53,7 @@ describe('isObject test', function () { }); // new Class() - function Class() {}; + function Class() {} it(`isObject(new Class()) === true`, function () { isObject(new Class()).should.equal(true); }); diff --git a/test/isPhone.test.js b/test/isPhone.test.js index 5ca61f1..d56938e 100644 --- a/test/isPhone.test.js +++ b/test/isPhone.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isPhone test', function () { +describe('isPhone', function () { // '18505505933' it(`isPhone('18505505933') === true`, function () { isPhone('18505505933').should.equal(true); diff --git a/test/isPlainObject.test.js b/test/isPlainObject.test.js index 1337563..5317f46 100644 --- a/test/isPlainObject.test.js +++ b/test/isPlainObject.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isPlainObject test', function () { +describe('isPlainObject', function () { // {} it(`isPlainObject({}) === true`, function () { isPlainObject({}).should.equal(true); @@ -28,19 +27,19 @@ describe('isPlainObject test', function () { isPlainObject(new Date()).should.equal(false); }); - // Object({}) - it(`isPlainObject(Object({})) === true`, function () { - isPlainObject(Object({})).should.equal(true); - }); - // Object('3') it(`isPlainObject(Object('3')) === false`, function () { isPlainObject(Object('3')).should.equal(false); }); - // new Object('3') - it(`isPlainObject(new Object('3')) === false`, function () { - isPlainObject(new Object('3')).should.equal(false); + // Object([]) + it(`isPlainObject(Object([])) === false`, function () { + isPlainObject(Object([])).should.equal(false); + }); + + // Object({}) + it(`isPlainObject(Object({})) === true`, function () { + isPlainObject(Object({})).should.equal(true); }); // null diff --git a/test/isPositiveInteger.test.js b/test/isPositiveInteger.test.js index 57364b8..e302991 100644 --- a/test/isPositiveInteger.test.js +++ b/test/isPositiveInteger.test.js @@ -6,38 +6,132 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isPositiveInteger test', function () { +describe('isPositiveInteger', function () { + // .3 + it(`isPositiveInteger(.3) === false`, function () { + isPositiveInteger(.3).should.equal(false); + }); + // 3 it(`isPositiveInteger(3) === true`, function () { isPositiveInteger(3).should.equal(true); }); + // 3. + it(`isPositiveInteger(3.) === true`, function () { + isPositiveInteger(3.).should.equal(true); + }); + + // 3.3 + it(`isPositiveInteger(3.3) === false`, function () { + isPositiveInteger(3.3).should.equal(false); + }); + + // '.3' + it(`isPositiveInteger('.3') === false`, function () { + isPositiveInteger('.3').should.equal(false); + }); + // '3' it(`isPositiveInteger('3') === true`, function () { isPositiveInteger('3').should.equal(true); }); + // '3.' + it(`isPositiveInteger('3.') === false`, function () { + isPositiveInteger('3.').should.equal(false); + }); + + // '3.3' + it(`isPositiveInteger('3.3') === false`, function () { + isPositiveInteger('3.3 ').should.equal(false); + }); + + // .3 + it(`isPositiveInteger(.3, {isStrict: true}) === false`, function () { + isPositiveInteger(.3, {isStrict: true}).should.equal(false); + }); + // 3 it(`isPositiveInteger(3, {isStrict: true}) === true`, function () { isPositiveInteger(3, {isStrict: true}).should.equal(true); }); + // 3. + it(`isPositiveInteger(3., {isStrict: true}) === true`, function () { + isPositiveInteger(3., {isStrict: true}).should.equal(true); + }); + + // 3.3 + it(`isPositiveInteger(3.3, {isStrict: true}) === false`, function () { + isPositiveInteger(3.3, {isStrict: true}).should.equal(false); + }); + + // '.3' + it(`isPositiveInteger('.3', {isStrict: true}) === false`, function () { + isPositiveInteger('.3', {isStrict: true}).should.equal(false); + }); + // '3' it(`isPositiveInteger('3', {isStrict: true}) === false`, function () { isPositiveInteger('3', {isStrict: true}).should.equal(false); }); + // '3.' + it(`isPositiveInteger('3.', {isStrict: true}) === false`, function () { + isPositiveInteger('3.', {isStrict: true}).should.equal(false); + }); + + // '3.3' + it(`isPositiveInteger('3.3', {isStrict: true}) === false`, function () { + isPositiveInteger('3.3', {isStrict: true}).should.equal(false); + }); + // 0 it(`isPositiveInteger(0) === false`, function () { isPositiveInteger(0).should.equal(false); }); + // 0. + it(`isPositiveInteger(0.) === false`, function () { + isPositiveInteger(0.).should.equal(false); + }); + + // .0 + it(`isPositiveInteger(.0) === false`, function () { + isPositiveInteger(.0).should.equal(false); + }); + + // 0.0 + it(`isPositiveInteger(0.0) === false`, function () { + isPositiveInteger(0.0).should.equal(false); + }); + // '0' it(`isPositiveInteger('0') === false`, function () { isPositiveInteger('0').should.equal(false); }); + // '0.' + it(`isPositiveInteger('0.') === false`, function () { + isPositiveInteger('0.').should.equal(false); + }); + + // '.0' + it(`isPositiveInteger('.0') === false`, function () { + isPositiveInteger('.0').should.equal(false); + }); + + // '0.0' + it(`isPositiveInteger('0.0') === false`, function () { + isPositiveInteger('0.0').should.equal(false); + }); + + // '.' + it(`isPositiveInteger('.') === false`, function () { + isPositiveInteger('.').should.equal(false); + }); + // 0 it(`isPositiveInteger(0, {isStrict: true}) === false`, function () { isPositiveInteger(0, {isStrict: true}).should.equal(false); @@ -48,54 +142,69 @@ describe('isPositiveInteger test', function () { isPositiveInteger('0', {isStrict: true}).should.equal(false); }); + // -.3 + it(`isPositiveInteger(-.3) === false`, function () { + isPositiveInteger(-.3).should.equal(false); + }); + // -3 it(`isPositiveInteger(-3) === false`, function () { isPositiveInteger(-3).should.equal(false); }); - // '-3' - it(`isPositiveInteger('-3') === false`, function () { - isPositiveInteger('-3').should.equal(false); + // -3. + it(`isPositiveInteger(-3.) === false`, function () { + isPositiveInteger(-3.).should.equal(false); }); - // -3 - it(`isPositiveInteger(-3, {isStrict: true}) === false`, function () { - isPositiveInteger(-3, {isStrict: true}).should.equal(false); + // -3.3 + it(`isPositiveInteger(-3.3) === false`, function () { + isPositiveInteger(-3.3).should.equal(false); + }); + + // '-.3' + it(`isPositiveInteger('-.3') === false`, function () { + isPositiveInteger('-.3').should.equal(false); }); // '-3' - it(`isPositiveInteger('-3', {isStrict: true}) === false`, function () { - isPositiveInteger('-3', {isStrict: true}).should.equal(false); + it(`isPositiveInteger('-3') === false`, function () { + isPositiveInteger('-3').should.equal(false); }); - // 3.3 - it(`isPositiveInteger(3.3) === false`, function () { - isPositiveInteger(3.3).should.equal(false); + // '-3.' + it(`isPositiveInteger('-3.') === false`, function () { + isPositiveInteger('-3.').should.equal(false); }); - // '3.3' - it(`isPositiveInteger('3.3') === false`, function () { - isPositiveInteger('3.3').should.to.be.equal(false); + // '-3.3' + it(`isPositiveInteger('-3.3') === false`, function () { + isPositiveInteger('-3.3').should.equal(false); }); - // 3.3 - it(`isPositiveInteger(3.3, {isStrict: true}) === false`, function () { - isPositiveInteger(3.3, {isStrict: true}).should.equal(false); + // '--3' + it(`isPositiveInteger('--3') === false`, function () { + isPositiveInteger('--3').should.equal(false); }); - // '3.3' - it(`isPositiveInteger('3.3', {isStrict: true}) === false`, function () { - isPositiveInteger('3.3', {isStrict: true}).should.equal(false); + // '-3-3' + it(`isPositiveInteger('-3-3') === false`, function () { + isPositiveInteger('-3-3').should.equal(false); }); - // -3.3 - it(`isPositiveInteger(-3.3) === false`, function () { - isPositiveInteger(-3.3).should.equal(false); + // -.3 + it(`isPositiveInteger(-.3, {isStrict: true}) === false`, function () { + isPositiveInteger(-.3, {isStrict: true}).should.equal(false); }); - // '-3.3' - it(`isPositiveInteger('-3.3') === false`, function () { - isPositiveInteger('-3.3').should.equal(false); + // -3 + it(`isPositiveInteger(-3, {isStrict: true}) === false`, function () { + isPositiveInteger(-3, {isStrict: true}).should.equal(false); + }); + + // -3. + it(`isPositiveInteger(-3., {isStrict: true}) === false`, function () { + isPositiveInteger(-3., {isStrict: true}).should.equal(false); }); // -3.3 @@ -103,19 +212,24 @@ describe('isPositiveInteger test', function () { isPositiveInteger(-3.3, {isStrict: true}).should.equal(false); }); - // '-3.3' - it(`isPositiveInteger('-3.3', {isStrict: true}) === false`, function () { - isPositiveInteger('-3.3', {isStrict: true}).should.equal(false); + // '-.3' + it(`isPositiveInteger('-.3', {isStrict: true}) === false`, function () { + isPositiveInteger('-.3', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isPositiveInteger(Number.POSITIVE_INFINITY) === false`, function () { - isPositiveInteger(Number.POSITIVE_INFINITY).should.equal(false); + // '-3' + it(`isPositiveInteger('-3', {isStrict: true}) === false`, function () { + isPositiveInteger('-3', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isPositiveInteger(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function () { - isPositiveInteger(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + // '-3.' + it(`isPositiveInteger('-3.', {isStrict: true}) === false`, function () { + isPositiveInteger('-3.', {isStrict: true}).should.equal(false); + }); + + // '-3.3' + it(`isPositiveInteger('-3.3', {isStrict: true}) === false`, function () { + isPositiveInteger('-3.3', {isStrict: true}).should.equal(false); }); // '' @@ -152,4 +266,44 @@ describe('isPositiveInteger test', function () { it(`isPositiveInteger(-Infinity) === false`, function () { isPositiveInteger(Number.NEGATIVE_INFINITY).should.equal(false); }); + + // Object(3) + it(`isPositiveInteger(Object(3)) === true`, function () { + isPositiveInteger(Object(3)).should.equal(true); + }); + + // Object('3') + it(`isPositiveInteger(Object('3')) === true`, function () { + isPositiveInteger(Object('3')).should.equal(true); + }); + + // Object(3) + it(`isPositiveInteger(Object(3), {isStrict: true}) === true`, function () { + isPositiveInteger(Object(3), {isStrict: true}).should.equal(true); + }); + + // Object('3') + it(`isPositiveInteger(Object('3'), {isStrict: true}) === false`, function () { + isPositiveInteger(Object('3'), {isStrict: true}).should.equal(false); + }); + + // Object(-3) + it(`isPositiveInteger(Object(-3)) === false`, function () { + isPositiveInteger(Object(-3)).should.equal(false); + }); + + // Object('-3') + it(`isPositiveInteger(Object('-3')) === false`, function () { + isPositiveInteger(Object('-3')).should.equal(false); + }); + + // Object(-3) + it(`isPositiveInteger(Object(-3), {isStrict: true}) === false`, function () { + isPositiveInteger(Object(-3), {isStrict: true}).should.equal(false); + }); + + // Object('-3') + it(`isPositiveInteger(Object('-3'), {isStrict: true}) === false`, function () { + isPositiveInteger(Object('-3'), {isStrict: true}).should.equal(false); + }); }); diff --git a/test/isPositiveNumber.test.js b/test/isPositiveNumber.test.js index 429e516..5e3beb7 100644 --- a/test/isPositiveNumber.test.js +++ b/test/isPositiveNumber.test.js @@ -6,38 +6,267 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isPositiveNumber test', function () { +describe('isPositiveNumber', function () { + // .3 + it(`isPositiveNumber(.3) === true`, function () { + isPositiveNumber(.3).should.equal(true); + }); + + // 0.3 + it(`isPositiveNumber(0.3) === true`, function () { + isPositiveNumber(0.3).should.equal(true); + }); + + // 0.35 + it(`isPositiveNumber(0.35) === true`, function () { + isPositiveNumber(0.35).should.equal(true); + }); + + // 0.356 + it(`isPositiveNumber(0.356) === true`, function () { + isPositiveNumber(0.356).should.equal(true); + }); + + // '.3' + it(`isPositiveNumber('.3') === true`, function () { + isPositiveNumber('.3').should.equal(true); + }); + + // '0.3' + it(`isPositiveNumber('0.3') === true`, function () { + isPositiveNumber('0.3').should.equal(true); + }); + + // '0.35' + it(`isPositiveNumber('0.35') === true`, function () { + isPositiveNumber('0.35').should.equal(true); + }); + + // '0.356' + it(`isPositiveNumber('0.356') === true`, function () { + isPositiveNumber('0.356').should.equal(true); + }); + + // '00.356' + it(`isPositiveNumber('00.356') === false`, function () { + isPositiveNumber('00.356').should.equal(false); + }); + + // '0.3.56' + it(`isPositiveNumber('0.3.56') === false`, function () { + isPositiveNumber('0.3.56').should.equal(false); + }); + + // '0.356.' + it(`isPositiveNumber('0.356.') === false`, function () { + isPositiveNumber('0.356.').should.equal(false); + }); + + // .3 + it(`isPositiveNumber(.3, {isStrict: true}) === true`, function () { + isPositiveNumber(.3, {isStrict: true}).should.equal(true); + }); + + // 0.3 + it(`isPositiveNumber(0.3, {isStrict: true}) === true`, function () { + isPositiveNumber(0.3, {isStrict: true}).should.equal(true); + }); + + // 0.35 + it(`isPositiveNumber(0.35, {isStrict: true}) === true`, function () { + isPositiveNumber(0.35, {isStrict: true}).should.equal(true); + }); + + // 0.356 + it(`isPositiveNumber(0.356, {isStrict: true}) === true`, function () { + isPositiveNumber(0.356, {isStrict: true}).should.equal(true); + }); + + // '.3' + it(`isPositiveNumber('.3', {isStrict: true}) === false`, function () { + isPositiveNumber('.3', {isStrict: true}).should.equal(false); + }); + + // '0.3' + it(`isPositiveNumber('0.3', {isStrict: true}) === false`, function () { + isPositiveNumber('0.3', {isStrict: true}).should.equal(false); + }); + + // '0.35' + it(`isPositiveNumber('0.35', {isStrict: true}) === false`, function () { + isPositiveNumber('0.35', {isStrict: true}).should.equal(false); + }); + + // '0.356' + it(`isPositiveNumber('0.356', {isStrict: true}) === false`, function () { + isPositiveNumber('0.356', {isStrict: true}).should.equal(false); + }); + // 3 it(`isPositiveNumber(3) === true`, function () { isPositiveNumber(3).should.equal(true); }); + // 3.5 + it(`isPositiveNumber(3.5) === true`, function () { + isPositiveNumber(3.5).should.equal(true); + }); + + // 3.56 + it(`isPositiveNumber(3.56) === true`, function () { + isPositiveNumber(3.56).should.equal(true); + }); + + // 30.56 + it(`isPositiveNumber(30.56) === true`, function () { + isPositiveNumber(30.56).should.equal(true); + }); + + // 30. + it(`isPositiveNumber(30.) === true`, function () { + isPositiveNumber(30.).should.equal(true); + }); + // '3' it(`isPositiveNumber('3') === true`, function () { isPositiveNumber('3').should.equal(true); }); + // '3.5' + it(`isPositiveNumber('3.5') === true`, function () { + isPositiveNumber('3.5').should.equal(true); + }); + + // '3.56' + it(`isPositiveNumber('3.56') === true`, function () { + isPositiveNumber('3.56').should.equal(true); + }); + + // '30.56' + it(`isPositiveNumber('30.56') === true`, function () { + isPositiveNumber('30.56').should.equal(true); + }); + + // '30.' + it(`isPositiveNumber('30.') === true`, function () { + isPositiveNumber('30.').should.equal(true); + }); + + // '30.5.6' + it(`isPositiveNumber('30.5.6') === false`, function () { + isPositiveNumber('30.5.6').should.equal(false); + }); + + // '30.56.' + it(`isPositiveNumber('30.56.') === false`, function () { + isPositiveNumber('30.56.').should.equal(false); + }); + // 3 it(`isPositiveNumber(3, {isStrict: true}) === true`, function () { isPositiveNumber(3, {isStrict: true}).should.equal(true); }); + // 3.5 + it(`isPositiveNumber(3.5, {isStrict: true}) === true`, function () { + isPositiveNumber(3.5, {isStrict: true}).should.equal(true); + }); + + // 3.56 + it(`isPositiveNumber(3.56, {isStrict: true}) === true`, function () { + isPositiveNumber(3.56, {isStrict: true}).should.equal(true); + }); + + // 30.56 + it(`isPositiveNumber(30.56, {isStrict: true}) === true`, function () { + isPositiveNumber(30.56, {isStrict: true}).should.equal(true); + }); + + // 30. + it(`isPositiveNumber(30., {isStrict: true}) === true`, function () { + isPositiveNumber(30., {isStrict: true}).should.equal(true); + }); + // '3' it(`isPositiveNumber('3', {isStrict: true}) === false`, function () { isPositiveNumber('3', {isStrict: true}).should.equal(false); }); + // '3.5' + it(`isPositiveNumber('3.5', {isStrict: true}) === false`, function () { + isPositiveNumber('3.5', {isStrict: true}).should.equal(false); + }); + + // '3.56' + it(`isPositiveNumber('3.56', {isStrict: true}) === false`, function () { + isPositiveNumber('3.56', {isStrict: true}).should.equal(false); + }); + + // '30.56' + it(`isPositiveNumber('30.56', {isStrict: true}) === false`, function () { + isPositiveNumber('30.56', {isStrict: true}).should.equal(false); + }); + + // '30.' + it(`isPositiveNumber('30.', {isStrict: true}) === false`, function () { + isPositiveNumber('30.', {isStrict: true}).should.equal(false); + }); + // 0 it(`isPositiveNumber(0) === false`, function () { isPositiveNumber(0).should.equal(false); }); + // +0 + it(`isPositiveNumber(+0) === false`, function () { + isPositiveNumber(+0).should.equal(false); + }); + + // -0 + it(`isPositiveNumber(-0) === false`, function () { + isPositiveNumber(-0).should.equal(false); + }); + + // 0. + it(`isPositiveNumber(0.) === false`, function () { + isPositiveNumber(0.).should.equal(false); + }); + + // .0 + it(`isPositiveNumber(.0) === false`, function () { + isPositiveNumber(.0).should.equal(false); + }); + // '0' it(`isPositiveNumber('0') === false`, function () { isPositiveNumber('0').should.equal(false); }); + // '+0' + it(`isPositiveNumber('+0') === false`, function () { + isPositiveNumber('+0').should.equal(false); + }); + + // '-0' + it(`isPositiveNumber('-0') === false`, function () { + isPositiveNumber('-0').should.equal(false); + }); + + // '0.' + it(`isPositiveNumber('0.') === false`, function () { + isPositiveNumber('0.').should.equal(false); + }); + + // '.' + it(`isPositiveNumber('.') === false`, function () { + isPositiveNumber('.').should.equal(false); + }); + + // '.0' + it(`isPositiveNumber('.0') === false`, function () { + isPositiveNumber('.0').should.equal(false); + }); + // 0 it(`isPositiveNumber(0, {isStrict: true}) === false`, function () { isPositiveNumber(0, {isStrict: true}).should.equal(false); @@ -48,34 +277,184 @@ describe('isPositiveNumber test', function () { isPositiveNumber('0', {isStrict: true}).should.equal(false); }); + // -.3 + it(`isPositiveNumber(-.3) === false`, function () { + isPositiveNumber(-.3).should.equal(false); + }); + + // -0.3 + it(`isPositiveNumber(-0.3) === false`, function () { + isPositiveNumber(-0.3).should.equal(false); + }); + + // -0.35 + it(`isPositiveNumber(-0.35) === false`, function () { + isPositiveNumber(-0.35).should.equal(false); + }); + + // -0.356 + it(`isPositiveNumber(-0.356) === false`, function () { + isPositiveNumber(-0.356).should.equal(false); + }); + + // '-.3' + it(`isPositiveNumber('-.3') === false`, function () { + isPositiveNumber('-.3').should.equal(false); + }); + + // '-0.3' + it(`isPositiveNumber('-0.3') === false`, function () { + isPositiveNumber('-0.3').should.equal(false); + }); + + // '-0.35' + it(`isPositiveNumber('-0.35') === false`, function () { + isPositiveNumber('-0.35').should.equal(false); + }); + + // '-0.356' + it(`isPositiveNumber('-0.356') === false`, function () { + isPositiveNumber('-0.356').should.equal(false); + }); + + // -.3 + it(`isPositiveNumber(-.3, {isStrict: true}) === false`, function () { + isPositiveNumber(-.3, {isStrict: true}).should.equal(false); + }); + + // -0.3 + it(`isPositiveNumber(-0.3, {isStrict: true}) === false`, function () { + isPositiveNumber(-0.3, {isStrict: true}).should.equal(false); + }); + + // -0.35 + it(`isPositiveNumber(-0.35, {isStrict: true}) === false`, function () { + isPositiveNumber(-0.35, {isStrict: true}).should.equal(false); + }); + + // -0.356 + it(`isPositiveNumber(-0.356, {isStrict: true}) === false`, function () { + isPositiveNumber(-0.356, {isStrict: true}).should.equal(false); + }); + + // '-.3' + it(`isPositiveNumber('-.3', {isStrict: true}) === false`, function () { + isPositiveNumber('-.3', {isStrict: true}).should.equal(false); + }); + + // '-0.3' + it(`isPositiveNumber('-0.3', {isStrict: true}) === false`, function () { + isPositiveNumber('-0.3', {isStrict: true}).should.equal(false); + }); + + // '-0.35' + it(`isPositiveNumber('-0.35', {isStrict: true}) === false`, function () { + isPositiveNumber('-0.35', {isStrict: true}).should.equal(false); + }); + + // '-0.356' + it(`isPositiveNumber('-0.356', {isStrict: true}) === false`, function () { + isPositiveNumber('-0.356', {isStrict: true}).should.equal(false); + }); + // -3 it(`isPositiveNumber(-3) === false`, function () { isPositiveNumber(-3).should.equal(false); }); + // -3.5 + it(`isPositiveNumber(-3.5) === false`, function () { + isPositiveNumber(-3.5).should.equal(false); + }); + + // -3.56 + it(`isPositiveNumber(-3.56) === false`, function () { + isPositiveNumber(-3.56).should.equal(false); + }); + + // -30.56 + it(`isPositiveNumber(-30.56) === false`, function () { + isPositiveNumber(-30.56).should.equal(false); + }); + + // -30. + it(`isPositiveNumber(-30.) === false`, function () { + isPositiveNumber(-30.).should.equal(false); + }); + // '-3' it(`isPositiveNumber('-3') === false`, function () { isPositiveNumber('-3').should.equal(false); }); + // '-3.5' + it(`isPositiveNumber('-3.5') === false`, function () { + isPositiveNumber('-3.5').should.equal(false); + }); + + // '-3.56' + it(`isPositiveNumber('-3.56') === false`, function () { + isPositiveNumber('-3.56').should.equal(false); + }); + + // '-30.56' + it(`isPositiveNumber('-30.56') === false`, function () { + isPositiveNumber('-30.56').should.equal(false); + }); + + // '-30.' + it(`isPositiveNumber('-30.') === false`, function () { + isPositiveNumber('-30.').should.equal(false); + }); + // -3 it(`isPositiveNumber(-3, {isStrict: true}) === false`, function () { isPositiveNumber(-3, {isStrict: true}).should.equal(false); }); + // -3.5 + it(`isPositiveNumber(-3.5, {isStrict: true}) === false`, function () { + isPositiveNumber(-3.5, {isStrict: true}).should.equal(false); + }); + + // -3.56 + it(`isPositiveNumber(-3.56, {isStrict: true}) === false`, function () { + isPositiveNumber(-3.56, {isStrict: true}).should.equal(false); + }); + + // -30.56 + it(`isPositiveNumber(-30.56, {isStrict: true}) === false`, function () { + isPositiveNumber(-30.56, {isStrict: true}).should.equal(false); + }); + + // -30. + it(`isPositiveNumber(-30., {isStrict: true}) === false`, function () { + isPositiveNumber(-30., {isStrict: true}).should.equal(false); + }); + // '-3' it(`isPositiveNumber('-3', {isStrict: true}) === false`, function () { isPositiveNumber('-3', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isPositiveNumber(Number.POSITIVE_INFINITY) === false`, function () { - isPositiveNumber(Number.POSITIVE_INFINITY).should.equal(false); + // '-3.5' + it(`isPositiveNumber('-3.5', {isStrict: true}) === false`, function () { + isPositiveNumber('-3.5', {isStrict: true}).should.equal(false); + }); + + // '-3.56' + it(`isPositiveNumber('-3.56', {isStrict: true}) === false`, function () { + isPositiveNumber('-3.56', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isPositiveNumber(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function () { - isPositiveNumber(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + // '-30.56' + it(`isPositiveNumber('-30.56', {isStrict: true}) === false`, function () { + isPositiveNumber('-30.56', {isStrict: true}).should.equal(false); + }); + + // '-30.' + it(`isPositiveNumber('-30.', {isStrict: true}) === false`, function () { + isPositiveNumber('-30.', {isStrict: true}).should.equal(false); }); // '' @@ -112,4 +491,24 @@ describe('isPositiveNumber test', function () { it(`isPositiveNumber(-Infinity) === false`, function () { isPositiveNumber(Number.NEGATIVE_INFINITY).should.equal(false); }); + + // Object(3.56) + it(`isPositiveNumber(Object(3.56)) === true`, function () { + isPositiveNumber(Object(3.56)).should.equal(true); + }); + + // Object('3.56') + it(`isPositiveNumber(Object('3.56')) === true`, function () { + isPositiveNumber(Object('3.56')).should.equal(true); + }); + + // Object(3.56) + it(`isPositiveNumber(Object(3.56), {isStrict: true}) === true`, function () { + isPositiveNumber(Object(3.56), {isStrict: true}).should.equal(true); + }); + + // Object('3.56') + it(`isPositiveNumber(Object('3.56'), {isStrict: true}) === false`, function () { + isPositiveNumber(Object('3.56'), {isStrict: true}).should.equal(false); + }); }); diff --git a/test/isRealNumber.test.js b/test/isRealNumber.test.js index 03e73a6..cab23de 100644 --- a/test/isRealNumber.test.js +++ b/test/isRealNumber.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isRealNumber test', function () { +describe('isRealNumber', function () { // 3 it(`isRealNumber(3) === true`, function () { isRealNumber(3).should.equal(true); @@ -33,6 +32,11 @@ describe('isRealNumber test', function () { isRealNumber('3a').should.equal(false); }); + // '3a' + it(`isRealNumber('3a', {isStrict: true}) === false`, function () { + isRealNumber('3a', {isStrict: true}).should.equal(false); + }); + // NaN it(`isRealNumber(NaN) === false`, function () { isRealNumber(NaN).should.equal(false); @@ -48,6 +52,16 @@ describe('isRealNumber test', function () { isRealNumber(Number.NEGATIVE_INFINITY).should.equal(true); }); + // MAX_SAFE_INTEGER + it(`isRealNumber(Number.MAX_SAFE_INTEGER) === true`, function () { + isRealNumber(Number.MAX_SAFE_INTEGER).should.equal(true); + }); + + // MIN_SAFE_INTEGER + it(`isRealNumber(Number.MIN_SAFE_INTEGER) === true`, function () { + isRealNumber(Number.MIN_SAFE_INTEGER).should.equal(true); + }); + // '' it(`isRealNumber('') === false`, function () { isRealNumber('').should.equal(false); @@ -68,16 +82,6 @@ describe('isRealNumber test', function () { isRealNumber(undefined).should.equal(false); }); - // Number(3) - it(`isRealNumber(Number(3)) === true`, function () { - isRealNumber(Number(3)).should.equal(true); - }); - - // new Number(3) - it(`isRealNumber(new Number(3)) === true`, function () { - isRealNumber(new Number(3)).should.equal(true); - }); - // {} it(`isRealNumber({}) === false`, function () { isRealNumber({}).should.equal(false); @@ -93,6 +97,11 @@ describe('isRealNumber test', function () { isRealNumber(Object('3')).should.equal(true); }); + // Object(3) + it(`isRealNumber(Object(3), {isStrict: true}) === true`, function () { + isRealNumber(Object(3), {isStrict: true}).should.equal(true); + }); + // Object('3') it(`isRealNumber(Object('3'), {isStrict: true}) === false`, function () { isRealNumber(Object('3'), {isStrict: true}).should.equal(false); diff --git a/test/isString.test.js b/test/isString.test.js index 1553176..64658d7 100644 --- a/test/isString.test.js +++ b/test/isString.test.js @@ -6,16 +6,15 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isString test', function () { +describe('isString', function () { // '' it(`isString('') === true`, function () { isString('').should.equal(true); }); - // ' ' - it(`isString(' ') === true`, function () { - isString(' ').should.equal(true); + // ' ' + it(`isString(' ') === true`, function () { + isString(' ').should.equal(true); }); // '3' @@ -43,14 +42,9 @@ describe('isString test', function () { isString(true).should.equal(false); }); - // String('3') - it(`isString(String('3')) === true`, function () { - isString(String('3')).should.equal(true); - }); - - // new String('3') - it(`isString(new String('3')) === true`, function () { - isString(new String('3')).should.equal(true); + // false + it(`isString(false) === false`, function () { + isString(false).should.equal(false); }); // {} @@ -58,13 +52,18 @@ describe('isString test', function () { isString({}).should.equal(false); }); - // Object('3') - it(`isString(Object('3')) === true`, function () { - isString(Object('3')).should.equal(true); + // [] + it(`isString([]) === false`, function () { + isString([]).should.equal(false); }); // Object(3) it(`isString(Object(3)) === false`, function () { isString(Object(3)).should.equal(false); }); + + // Object('3') + it(`isString(Object('3')) === true`, function () { + isString(Object('3')).should.equal(true); + }); }); diff --git a/test/isTelephone.test.js b/test/isTelephone.test.js index 933cb78..4df0ca1 100644 --- a/test/isTelephone.test.js +++ b/test/isTelephone.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isTelephone test', function () { +describe('isTelephone', function () { // '7632614' it(`isTelephone('7632614') === true`, function () { isTelephone('7632614').should.equal(true); diff --git a/test/isUnEmptyString.test.js b/test/isUnEmptyString.test.js index 5a59e96..ed9d5ce 100644 --- a/test/isUnEmptyString.test.js +++ b/test/isUnEmptyString.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isUnEmptyString test', function () { +describe('isUnEmptyString', function () { // 3 it(`isUnEmptyString(3) === false`, function () { isUnEmptyString(3).should.equal(false); @@ -28,19 +27,19 @@ describe('isUnEmptyString test', function () { isUnEmptyString('').should.equal(false); }); + // ' ' + it(`isUnEmptyString(' ') === false`, function () { + isUnEmptyString(' ').should.equal(false); + }); + // '' it(`isUnEmptyString('', {isStrict: false}) === false`, function () { isUnEmptyString('', {isStrict: false}).should.equal(false); }); - // ' ' - it(`isUnEmptyString(' ') === false`, function () { - isUnEmptyString(' ').should.equal(false); - }); - - // ' ' - it(`isUnEmptyString(' ', {isStrict: false}) === true`, function () { - isUnEmptyString(' ', {isStrict: false}).should.equal(true); + // ' ' + it(`isUnEmptyString(' ', {isStrict: false}) === true`, function () { + isUnEmptyString(' ', {isStrict: false}).should.equal(true); }); // null diff --git a/test/isUnNegativeInteger.test.js b/test/isUnNegativeInteger.test.js index 9db3242..0d1731a 100644 --- a/test/isUnNegativeInteger.test.js +++ b/test/isUnNegativeInteger.test.js @@ -6,38 +6,132 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isUnNegativeInteger test', function () { +describe('isUnNegativeInteger', function () { + // .3 + it(`isUnNegativeInteger(.3) === false`, function () { + isUnNegativeInteger(.3).should.equal(false); + }); + // 3 it(`isUnNegativeInteger(3) === true`, function () { isUnNegativeInteger(3).should.equal(true); }); + // 3. + it(`isUnNegativeInteger(3.) === true`, function () { + isUnNegativeInteger(3.).should.equal(true); + }); + + // 3.3 + it(`isUnNegativeInteger(3.3) === false`, function () { + isUnNegativeInteger(3.3).should.equal(false); + }); + + // '.3' + it(`isUnNegativeInteger('.3') === false`, function () { + isUnNegativeInteger('.3').should.equal(false); + }); + // '3' it(`isUnNegativeInteger('3') === true`, function () { isUnNegativeInteger('3').should.equal(true); }); + // '3.' + it(`isUnNegativeInteger('3.') === false`, function () { + isUnNegativeInteger('3.').should.equal(false); + }); + + // '3.3' + it(`isUnNegativeInteger('3.3') === false`, function () { + isUnNegativeInteger('3.3 ').should.equal(false); + }); + + // .3 + it(`isUnNegativeInteger(.3, {isStrict: true}) === false`, function () { + isUnNegativeInteger(.3, {isStrict: true}).should.equal(false); + }); + // 3 it(`isUnNegativeInteger(3, {isStrict: true}) === true`, function () { isUnNegativeInteger(3, {isStrict: true}).should.equal(true); }); + // 3. + it(`isUnNegativeInteger(3., {isStrict: true}) === true`, function () { + isUnNegativeInteger(3., {isStrict: true}).should.equal(true); + }); + + // 3.3 + it(`isUnNegativeInteger(3.3, {isStrict: true}) === false`, function () { + isUnNegativeInteger(3.3, {isStrict: true}).should.equal(false); + }); + + // '.3' + it(`isUnNegativeInteger('.3', {isStrict: true}) === false`, function () { + isUnNegativeInteger('.3', {isStrict: true}).should.equal(false); + }); + // '3' it(`isUnNegativeInteger('3', {isStrict: true}) === false`, function () { isUnNegativeInteger('3', {isStrict: true}).should.equal(false); }); + // '3.' + it(`isUnNegativeInteger('3.', {isStrict: true}) === false`, function () { + isUnNegativeInteger('3.', {isStrict: true}).should.equal(false); + }); + + // '3.3' + it(`isUnNegativeInteger('3.3', {isStrict: true}) === false`, function () { + isUnNegativeInteger('3.3', {isStrict: true}).should.equal(false); + }); + // 0 it(`isUnNegativeInteger(0) === true`, function () { isUnNegativeInteger(0).should.equal(true); }); + // 0. + it(`isUnNegativeInteger(0.) === true`, function () { + isUnNegativeInteger(0.).should.equal(true); + }); + + // .0 + it(`isUnNegativeInteger(.0) === true`, function () { + isUnNegativeInteger(.0).should.equal(true); + }); + + // 0.0 + it(`isUnNegativeInteger(0.0) === true`, function () { + isUnNegativeInteger(0.0).should.equal(true); + }); + // '0' it(`isUnNegativeInteger('0') === true`, function () { isUnNegativeInteger('0').should.equal(true); }); + // '0.' + it(`isUnNegativeInteger('0.') === false`, function () { + isUnNegativeInteger('0.').should.equal(false); + }); + + // '.0' + it(`isUnNegativeInteger('.0') === false`, function () { + isUnNegativeInteger('.0').should.equal(false); + }); + + // '0.0' + it(`isUnNegativeInteger('0.0') === false`, function () { + isUnNegativeInteger('0.0').should.equal(false); + }); + + // '.' + it(`isUnNegativeInteger('.') === false`, function () { + isUnNegativeInteger('.').should.equal(false); + }); + // 0 it(`isUnNegativeInteger(0, {isStrict: true}) === true`, function () { isUnNegativeInteger(0, {isStrict: true}).should.equal(true); @@ -48,54 +142,69 @@ describe('isUnNegativeInteger test', function () { isUnNegativeInteger('0', {isStrict: true}).should.equal(false); }); + // -.3 + it(`isUnNegativeInteger(-.3) === false`, function () { + isUnNegativeInteger(-.3).should.equal(false); + }); + // -3 it(`isUnNegativeInteger(-3) === false`, function () { isUnNegativeInteger(-3).should.equal(false); }); - // '-3' - it(`isUnNegativeInteger('-3') === false`, function () { - isUnNegativeInteger('-3').should.equal(false); + // -3. + it(`isUnNegativeInteger(-3.) === false`, function () { + isUnNegativeInteger(-3.).should.equal(false); }); - // -3 - it(`isUnNegativeInteger(-3, {isStrict: true}) === false`, function () { - isUnNegativeInteger(-3, {isStrict: true}).should.equal(false); + // -3.3 + it(`isUnNegativeInteger(-3.3) === false`, function () { + isUnNegativeInteger(-3.3).should.equal(false); + }); + + // '-.3' + it(`isUnNegativeInteger('-.3') === false`, function () { + isUnNegativeInteger('-.3').should.equal(false); }); // '-3' - it(`isUnNegativeInteger('-3', {isStrict: true}) === false`, function () { - isUnNegativeInteger('-3', {isStrict: true}).should.equal(false); + it(`isUnNegativeInteger('-3') === false`, function () { + isUnNegativeInteger('-3').should.equal(false); }); - // 3.3 - it(`isUnNegativeInteger(3.3) === false`, function () { - isUnNegativeInteger(3.3).should.equal(false); + // '-3.' + it(`isUnNegativeInteger('-3.') === false`, function () { + isUnNegativeInteger('-3.').should.equal(false); }); - // '3.3' - it(`isUnNegativeInteger('3.3') === false`, function () { - isUnNegativeInteger('3.3').should.equal(false); + // '-3.3' + it(`isUnNegativeInteger('-3.3') === false`, function () { + isUnNegativeInteger('-3.3').should.equal(false); }); - // 3.3 - it(`isUnNegativeInteger(3.3, {isStrict: true}) === false`, function () { - isUnNegativeInteger(3.3, {isStrict: true}).should.equal(false); + // '--3' + it(`isUnNegativeInteger('--3') === false`, function () { + isUnNegativeInteger('--3').should.equal(false); }); - // '3.3' - it(`isUnNegativeInteger('3.3', {isStrict: true}) === false`, function () { - isUnNegativeInteger('3.3', {isStrict: true}).should.equal(false); + // '-3-3' + it(`isUnNegativeInteger('-3-3') === false`, function () { + isUnNegativeInteger('-3-3').should.equal(false); }); - // -3.3 - it(`isUnNegativeInteger(-3.3) === false`, function () { - isUnNegativeInteger(-3.3).should.equal(false); + // -.3 + it(`isUnNegativeInteger(-.3, {isStrict: true}) === false`, function () { + isUnNegativeInteger(-.3, {isStrict: true}).should.equal(false); }); - // '-3.3' - it(`isUnNegativeInteger('-3.3') === false`, function () { - isUnNegativeInteger('-3.3').should.equal(false); + // -3 + it(`isUnNegativeInteger(-3, {isStrict: true}) === false`, function () { + isUnNegativeInteger(-3, {isStrict: true}).should.equal(false); + }); + + // -3. + it(`isUnNegativeInteger(-3., {isStrict: true}) === false`, function () { + isUnNegativeInteger(-3., {isStrict: true}).should.equal(false); }); // -3.3 @@ -103,19 +212,24 @@ describe('isUnNegativeInteger test', function () { isUnNegativeInteger(-3.3, {isStrict: true}).should.equal(false); }); - // '-3.3' - it(`isUnNegativeInteger('-3.3', {isStrict: true}) === false`, function () { - isUnNegativeInteger('-3.3', {isStrict: true}).should.equal(false); + // '-.3' + it(`isUnNegativeInteger('-.3', {isStrict: true}) === false`, function () { + isUnNegativeInteger('-.3', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isUnNegativeInteger(Number.POSITIVE_INFINITY) === false`, function () { - isUnNegativeInteger(Number.POSITIVE_INFINITY).should.equal(false); + // '-3' + it(`isUnNegativeInteger('-3', {isStrict: true}) === false`, function () { + isUnNegativeInteger('-3', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isUnNegativeInteger(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function () { - isUnNegativeInteger(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + // '-3.' + it(`isUnNegativeInteger('-3.', {isStrict: true}) === false`, function () { + isUnNegativeInteger('-3.', {isStrict: true}).should.equal(false); + }); + + // '-3.3' + it(`isUnNegativeInteger('-3.3', {isStrict: true}) === false`, function () { + isUnNegativeInteger('-3.3', {isStrict: true}).should.equal(false); }); // '' @@ -152,4 +266,44 @@ describe('isUnNegativeInteger test', function () { it(`isUnNegativeInteger(-Infinity) === false`, function () { isUnNegativeInteger(Number.NEGATIVE_INFINITY).should.equal(false); }); + + // Object(3) + it(`isUnNegativeInteger(Object(3)) === true`, function () { + isUnNegativeInteger(Object(3)).should.equal(true); + }); + + // Object('3') + it(`isUnNegativeInteger(Object('3')) === true`, function () { + isUnNegativeInteger(Object('3')).should.equal(true); + }); + + // Object(3) + it(`isUnNegativeInteger(Object(3), {isStrict: true}) === true`, function () { + isUnNegativeInteger(Object(3), {isStrict: true}).should.equal(true); + }); + + // Object('3') + it(`isUnNegativeInteger(Object('3'), {isStrict: true}) === false`, function () { + isUnNegativeInteger(Object('3'), {isStrict: true}).should.equal(false); + }); + + // Object(-3) + it(`isUnNegativeInteger(Object(-3)) === false`, function () { + isUnNegativeInteger(Object(-3)).should.equal(false); + }); + + // Object('-3') + it(`isUnNegativeInteger(Object('-3')) === false`, function () { + isUnNegativeInteger(Object('-3')).should.equal(false); + }); + + // Object(-3) + it(`isUnNegativeInteger(Object(-3), {isStrict: true}) === false`, function () { + isUnNegativeInteger(Object(-3), {isStrict: true}).should.equal(false); + }); + + // Object('-3') + it(`isUnNegativeInteger(Object('-3'), {isStrict: true}) === false`, function () { + isUnNegativeInteger(Object('-3'), {isStrict: true}).should.equal(false); + }); }); diff --git a/test/isUnNegativeNumber.test.js b/test/isUnNegativeNumber.test.js index edbba8e..6549dfe 100644 --- a/test/isUnNegativeNumber.test.js +++ b/test/isUnNegativeNumber.test.js @@ -6,38 +6,267 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isUnNegativeNumber test', function () { +describe('isUnNegativeNumber', function () { + // .3 + it(`isUnNegativeNumber(.3) === true`, function () { + isUnNegativeNumber(.3).should.equal(true); + }); + + // 0.3 + it(`isUnNegativeNumber(0.3) === true`, function () { + isUnNegativeNumber(0.3).should.equal(true); + }); + + // 0.35 + it(`isUnNegativeNumber(0.35) === true`, function () { + isUnNegativeNumber(0.35).should.equal(true); + }); + + // 0.356 + it(`isUnNegativeNumber(0.356) === true`, function () { + isUnNegativeNumber(0.356).should.equal(true); + }); + + // '.3' + it(`isUnNegativeNumber('.3') === true`, function () { + isUnNegativeNumber('.3').should.equal(true); + }); + + // '0.3' + it(`isUnNegativeNumber('0.3') === true`, function () { + isUnNegativeNumber('0.3').should.equal(true); + }); + + // '0.35' + it(`isUnNegativeNumber('0.35') === true`, function () { + isUnNegativeNumber('0.35').should.equal(true); + }); + + // '0.356' + it(`isUnNegativeNumber('0.356') === true`, function () { + isUnNegativeNumber('0.356').should.equal(true); + }); + + // '00.356' + it(`isUnNegativeNumber('00.356') === false`, function () { + isUnNegativeNumber('00.356').should.equal(false); + }); + + // '0.3.56' + it(`isUnNegativeNumber('0.3.56') === false`, function () { + isUnNegativeNumber('0.3.56').should.equal(false); + }); + + // '0.356.' + it(`isUnNegativeNumber('0.356.') === false`, function () { + isUnNegativeNumber('0.356.').should.equal(false); + }); + + // .3 + it(`isUnNegativeNumber(.3, {isStrict: true}) === true`, function () { + isUnNegativeNumber(.3, {isStrict: true}).should.equal(true); + }); + + // 0.3 + it(`isUnNegativeNumber(0.3, {isStrict: true}) === true`, function () { + isUnNegativeNumber(0.3, {isStrict: true}).should.equal(true); + }); + + // 0.35 + it(`isUnNegativeNumber(0.35, {isStrict: true}) === true`, function () { + isUnNegativeNumber(0.35, {isStrict: true}).should.equal(true); + }); + + // 0.356 + it(`isUnNegativeNumber(0.356, {isStrict: true}) === true`, function () { + isUnNegativeNumber(0.356, {isStrict: true}).should.equal(true); + }); + + // '.3' + it(`isUnNegativeNumber('.3', {isStrict: true}) === false`, function () { + isUnNegativeNumber('.3', {isStrict: true}).should.equal(false); + }); + + // '0.3' + it(`isUnNegativeNumber('0.3', {isStrict: true}) === false`, function () { + isUnNegativeNumber('0.3', {isStrict: true}).should.equal(false); + }); + + // '0.35' + it(`isUnNegativeNumber('0.35', {isStrict: true}) === false`, function () { + isUnNegativeNumber('0.35', {isStrict: true}).should.equal(false); + }); + + // '0.356' + it(`isUnNegativeNumber('0.356', {isStrict: true}) === false`, function () { + isUnNegativeNumber('0.356', {isStrict: true}).should.equal(false); + }); + // 3 it(`isUnNegativeNumber(3) === true`, function () { isUnNegativeNumber(3).should.equal(true); }); + // 3.5 + it(`isUnNegativeNumber(3.5) === true`, function () { + isUnNegativeNumber(3.5).should.equal(true); + }); + + // 3.56 + it(`isUnNegativeNumber(3.56) === true`, function () { + isUnNegativeNumber(3.56).should.equal(true); + }); + + // 30.56 + it(`isUnNegativeNumber(30.56) === true`, function () { + isUnNegativeNumber(30.56).should.equal(true); + }); + + // 30. + it(`isUnNegativeNumber(30.) === true`, function () { + isUnNegativeNumber(30.).should.equal(true); + }); + // '3' it(`isUnNegativeNumber('3') === true`, function () { isUnNegativeNumber('3').should.equal(true); }); + // '3.5' + it(`isUnNegativeNumber('3.5') === true`, function () { + isUnNegativeNumber('3.5').should.equal(true); + }); + + // '3.56' + it(`isUnNegativeNumber('3.56') === true`, function () { + isUnNegativeNumber('3.56').should.equal(true); + }); + + // '30.56' + it(`isUnNegativeNumber('30.56') === true`, function () { + isUnNegativeNumber('30.56').should.equal(true); + }); + + // '30.' + it(`isUnNegativeNumber('30.') === true`, function () { + isUnNegativeNumber('30.').should.equal(true); + }); + + // '30.5.6' + it(`isUnNegativeNumber('30.5.6') === false`, function () { + isUnNegativeNumber('30.5.6').should.equal(false); + }); + + // '30.56.' + it(`isUnNegativeNumber('30.56.') === false`, function () { + isUnNegativeNumber('30.56.').should.equal(false); + }); + // 3 it(`isUnNegativeNumber(3, {isStrict: true}) === true`, function () { isUnNegativeNumber(3, {isStrict: true}).should.equal(true); }); + // 3.5 + it(`isUnNegativeNumber(3.5, {isStrict: true}) === true`, function () { + isUnNegativeNumber(3.5, {isStrict: true}).should.equal(true); + }); + + // 3.56 + it(`isUnNegativeNumber(3.56, {isStrict: true}) === true`, function () { + isUnNegativeNumber(3.56, {isStrict: true}).should.equal(true); + }); + + // 30.56 + it(`isUnNegativeNumber(30.56, {isStrict: true}) === true`, function () { + isUnNegativeNumber(30.56, {isStrict: true}).should.equal(true); + }); + + // 30. + it(`isUnNegativeNumber(30., {isStrict: true}) === true`, function () { + isUnNegativeNumber(30., {isStrict: true}).should.equal(true); + }); + // '3' it(`isUnNegativeNumber('3', {isStrict: true}) === false`, function () { isUnNegativeNumber('3', {isStrict: true}).should.equal(false); }); + // '3.5' + it(`isUnNegativeNumber('3.5', {isStrict: true}) === false`, function () { + isUnNegativeNumber('3.5', {isStrict: true}).should.equal(false); + }); + + // '3.56' + it(`isUnNegativeNumber('3.56', {isStrict: true}) === false`, function () { + isUnNegativeNumber('3.56', {isStrict: true}).should.equal(false); + }); + + // '30.56' + it(`isUnNegativeNumber('30.56', {isStrict: true}) === false`, function () { + isUnNegativeNumber('30.56', {isStrict: true}).should.equal(false); + }); + + // '30.' + it(`isUnNegativeNumber('30.', {isStrict: true}) === false`, function () { + isUnNegativeNumber('30.', {isStrict: true}).should.equal(false); + }); + // 0 - it(`isUnNegativeNumber(0) === false`, function () { + it(`isUnNegativeNumber(0) === true`, function () { isUnNegativeNumber(0).should.equal(true); }); + // +0 + it(`isUnNegativeNumber(+0) === true`, function () { + isUnNegativeNumber(+0).should.equal(true); + }); + + // -0 + it(`isUnNegativeNumber(-0) === true`, function () { + isUnNegativeNumber(-0).should.equal(true); + }); + + // 0. + it(`isUnNegativeNumber(0.) === true`, function () { + isUnNegativeNumber(0.).should.equal(true); + }); + + // .0 + it(`isUnNegativeNumber(.0) === true`, function () { + isUnNegativeNumber(.0).should.equal(true); + }); + // '0' - it(`isUnNegativeNumber('0') === false`, function () { + it(`isUnNegativeNumber('0') === true`, function () { isUnNegativeNumber('0').should.equal(true); }); + // '+0' + it(`isUnNegativeNumber('+0') === true`, function () { + isUnNegativeNumber('+0').should.equal(true); + }); + + // '-0' + it(`isUnNegativeNumber('-0') === true`, function () { + isUnNegativeNumber('-0').should.equal(true); + }); + + // '0.' + it(`isUnNegativeNumber('0.') === true`, function () { + isUnNegativeNumber('0.').should.equal(true); + }); + + // '.' + it(`isUnNegativeNumber('.') === false`, function () { + isUnNegativeNumber('.').should.equal(false); + }); + + // '.0' + it(`isUnNegativeNumber('.0') === true`, function () { + isUnNegativeNumber('.0').should.equal(true); + }); + // 0 it(`isUnNegativeNumber(0, {isStrict: true}) === true`, function () { isUnNegativeNumber(0, {isStrict: true}).should.equal(true); @@ -48,34 +277,184 @@ describe('isUnNegativeNumber test', function () { isUnNegativeNumber('0', {isStrict: true}).should.equal(false); }); + // -.3 + it(`isUnNegativeNumber(-.3) === false`, function () { + isUnNegativeNumber(-.3).should.equal(false); + }); + + // -0.3 + it(`isUnNegativeNumber(-0.3) === false`, function () { + isUnNegativeNumber(-0.3).should.equal(false); + }); + + // -0.35 + it(`isUnNegativeNumber(-0.35) === false`, function () { + isUnNegativeNumber(-0.35).should.equal(false); + }); + + // -0.356 + it(`isUnNegativeNumber(-0.356) === false`, function () { + isUnNegativeNumber(-0.356).should.equal(false); + }); + + // '-.3' + it(`isUnNegativeNumber('-.3') === false`, function () { + isUnNegativeNumber('-.3').should.equal(false); + }); + + // '-0.3' + it(`isUnNegativeNumber('-0.3') === false`, function () { + isUnNegativeNumber('-0.3').should.equal(false); + }); + + // '-0.35' + it(`isUnNegativeNumber('-0.35') === false`, function () { + isUnNegativeNumber('-0.35').should.equal(false); + }); + + // '-0.356' + it(`isUnNegativeNumber('-0.356') === false`, function () { + isUnNegativeNumber('-0.356').should.equal(false); + }); + + // -.3 + it(`isUnNegativeNumber(-.3, {isStrict: true}) === false`, function () { + isUnNegativeNumber(-.3, {isStrict: true}).should.equal(false); + }); + + // -0.3 + it(`isUnNegativeNumber(-0.3, {isStrict: true}) === false`, function () { + isUnNegativeNumber(-0.3, {isStrict: true}).should.equal(false); + }); + + // -0.35 + it(`isUnNegativeNumber(-0.35, {isStrict: true}) === false`, function () { + isUnNegativeNumber(-0.35, {isStrict: true}).should.equal(false); + }); + + // -0.356 + it(`isUnNegativeNumber(-0.356, {isStrict: true}) === false`, function () { + isUnNegativeNumber(-0.356, {isStrict: true}).should.equal(false); + }); + + // '-.3' + it(`isUnNegativeNumber('-.3', {isStrict: true}) === false`, function () { + isUnNegativeNumber('-.3', {isStrict: true}).should.equal(false); + }); + + // '-0.3' + it(`isUnNegativeNumber('-0.3', {isStrict: true}) === false`, function () { + isUnNegativeNumber('-0.3', {isStrict: true}).should.equal(false); + }); + + // '-0.35' + it(`isUnNegativeNumber('-0.35', {isStrict: true}) === false`, function () { + isUnNegativeNumber('-0.35', {isStrict: true}).should.equal(false); + }); + + // '-0.356' + it(`isUnNegativeNumber('-0.356', {isStrict: true}) === false`, function () { + isUnNegativeNumber('-0.356', {isStrict: true}).should.equal(false); + }); + // -3 it(`isUnNegativeNumber(-3) === false`, function () { isUnNegativeNumber(-3).should.equal(false); }); + // -3.5 + it(`isUnNegativeNumber(-3.5) === false`, function () { + isUnNegativeNumber(-3.5).should.equal(false); + }); + + // -3.56 + it(`isUnNegativeNumber(-3.56) === false`, function () { + isUnNegativeNumber(-3.56).should.equal(false); + }); + + // -30.56 + it(`isUnNegativeNumber(-30.56) === false`, function () { + isUnNegativeNumber(-30.56).should.equal(false); + }); + + // -30. + it(`isUnNegativeNumber(-30.) === false`, function () { + isUnNegativeNumber(-30.).should.equal(false); + }); + // '-3' it(`isUnNegativeNumber('-3') === false`, function () { isUnNegativeNumber('-3').should.equal(false); }); + // '-3.5' + it(`isUnNegativeNumber('-3.5') === false`, function () { + isUnNegativeNumber('-3.5').should.equal(false); + }); + + // '-3.56' + it(`isUnNegativeNumber('-3.56') === false`, function () { + isUnNegativeNumber('-3.56').should.equal(false); + }); + + // '-30.56' + it(`isUnNegativeNumber('-30.56') === false`, function () { + isUnNegativeNumber('-30.56').should.equal(false); + }); + + // '-30.' + it(`isUnNegativeNumber('-30.') === false`, function () { + isUnNegativeNumber('-30.').should.equal(false); + }); + // -3 it(`isUnNegativeNumber(-3, {isStrict: true}) === false`, function () { isUnNegativeNumber(-3, {isStrict: true}).should.equal(false); }); + // -3.5 + it(`isUnNegativeNumber(-3.5, {isStrict: true}) === false`, function () { + isUnNegativeNumber(-3.5, {isStrict: true}).should.equal(false); + }); + + // -3.56 + it(`isUnNegativeNumber(-3.56, {isStrict: true}) === false`, function () { + isUnNegativeNumber(-3.56, {isStrict: true}).should.equal(false); + }); + + // -30.56 + it(`isUnNegativeNumber(-30.56, {isStrict: true}) === false`, function () { + isUnNegativeNumber(-30.56, {isStrict: true}).should.equal(false); + }); + + // -30. + it(`isUnNegativeNumber(-30., {isStrict: true}) === false`, function () { + isUnNegativeNumber(-30., {isStrict: true}).should.equal(false); + }); + // '-3' it(`isUnNegativeNumber('-3', {isStrict: true}) === false`, function () { isUnNegativeNumber('-3', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isUnNegativeNumber(Number.POSITIVE_INFINITY) === false`, function () { - isUnNegativeNumber(Number.POSITIVE_INFINITY).should.equal(false); + // '-3.5' + it(`isUnNegativeNumber('-3.5', {isStrict: true}) === false`, function () { + isUnNegativeNumber('-3.5', {isStrict: true}).should.equal(false); + }); + + // '-3.56' + it(`isUnNegativeNumber('-3.56', {isStrict: true}) === false`, function () { + isUnNegativeNumber('-3.56', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isUnNegativeNumber(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function () { - isUnNegativeNumber(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + // '-30.56' + it(`isUnNegativeNumber('-30.56', {isStrict: true}) === false`, function () { + isUnNegativeNumber('-30.56', {isStrict: true}).should.equal(false); + }); + + // '-30.' + it(`isUnNegativeNumber('-30.', {isStrict: true}) === false`, function () { + isUnNegativeNumber('-30.', {isStrict: true}).should.equal(false); }); // '' @@ -112,4 +491,24 @@ describe('isUnNegativeNumber test', function () { it(`isUnNegativeNumber(-Infinity) === false`, function () { isUnNegativeNumber(Number.NEGATIVE_INFINITY).should.equal(false); }); + + // Object(3.56) + it(`isUnNegativeNumber(Object(3.56)) === true`, function () { + isUnNegativeNumber(Object(3.56)).should.equal(true); + }); + + // Object('3.56') + it(`isUnNegativeNumber(Object('3.56')) === true`, function () { + isUnNegativeNumber(Object('3.56')).should.equal(true); + }); + + // Object(3.56) + it(`isUnNegativeNumber(Object(3.56), {isStrict: true}) === true`, function () { + isUnNegativeNumber(Object(3.56), {isStrict: true}).should.equal(true); + }); + + // Object('3.56') + it(`isUnNegativeNumber(Object('3.56'), {isStrict: true}) === false`, function () { + isUnNegativeNumber(Object('3.56'), {isStrict: true}).should.equal(false); + }); }); diff --git a/test/isUnPositiveInteger.test.js b/test/isUnPositiveInteger.test.js index bfeb12c..19566e9 100644 --- a/test/isUnPositiveInteger.test.js +++ b/test/isUnPositiveInteger.test.js @@ -6,38 +6,132 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isUnPositiveInteger test', function () { +describe('isUnPositiveInteger', function () { + // .3 + it(`isUnPositiveInteger(.3) === false`, function () { + isUnPositiveInteger(.3).should.equal(false); + }); + // 3 it(`isUnPositiveInteger(3) === false`, function () { isUnPositiveInteger(3).should.equal(false); }); + // 3. + it(`isUnPositiveInteger(3.) === false`, function () { + isUnPositiveInteger(3.).should.equal(false); + }); + + // 3.3 + it(`isUnPositiveInteger(3.3) === false`, function () { + isUnPositiveInteger(3.3).should.equal(false); + }); + + // '.3' + it(`isUnPositiveInteger('.3') === false`, function () { + isUnPositiveInteger('.3').should.equal(false); + }); + // '3' it(`isUnPositiveInteger('3') === false`, function () { isUnPositiveInteger('3').should.equal(false); }); + // '3.' + it(`isUnPositiveInteger('3.') === false`, function () { + isUnPositiveInteger('3.').should.equal(false); + }); + + // '3.3' + it(`isUnPositiveInteger('3.3') === false`, function () { + isUnPositiveInteger('3.3 ').should.equal(false); + }); + + // .3 + it(`isUnPositiveInteger(.3, {isStrict: true}) === false`, function () { + isUnPositiveInteger(.3, {isStrict: true}).should.equal(false); + }); + // 3 it(`isUnPositiveInteger(3, {isStrict: true}) === false`, function () { isUnPositiveInteger(3, {isStrict: true}).should.equal(false); }); + // 3. + it(`isUnPositiveInteger(3., {isStrict: true}) === false`, function () { + isUnPositiveInteger(3., {isStrict: true}).should.equal(false); + }); + + // 3.3 + it(`isUnPositiveInteger(3.3, {isStrict: true}) === false`, function () { + isUnPositiveInteger(3.3, {isStrict: true}).should.equal(false); + }); + + // '.3' + it(`isUnPositiveInteger('.3', {isStrict: true}) === false`, function () { + isUnPositiveInteger('.3', {isStrict: true}).should.equal(false); + }); + // '3' it(`isUnPositiveInteger('3', {isStrict: true}) === false`, function () { isUnPositiveInteger('3', {isStrict: true}).should.equal(false); }); + // '3.' + it(`isUnPositiveInteger('3.', {isStrict: true}) === false`, function () { + isUnPositiveInteger('3.', {isStrict: true}).should.equal(false); + }); + + // '3.3' + it(`isUnPositiveInteger('3.3', {isStrict: true}) === false`, function () { + isUnPositiveInteger('3.3', {isStrict: true}).should.equal(false); + }); + // 0 it(`isUnPositiveInteger(0) === true`, function () { isUnPositiveInteger(0).should.equal(true); }); + // 0. + it(`isUnPositiveInteger(0.) === true`, function () { + isUnPositiveInteger(0.).should.equal(true); + }); + + // .0 + it(`isUnPositiveInteger(.0) === true`, function () { + isUnPositiveInteger(.0).should.equal(true); + }); + + // 0.0 + it(`isUnPositiveInteger(0.0) === true`, function () { + isUnPositiveInteger(0.0).should.equal(true); + }); + // '0' it(`isUnPositiveInteger('0') === true`, function () { isUnPositiveInteger('0').should.equal(true); }); + // '0.' + it(`isUnPositiveInteger('0.') === false`, function () { + isUnPositiveInteger('0.').should.equal(false); + }); + + // '.0' + it(`isUnPositiveInteger('.0') === false`, function () { + isUnPositiveInteger('.0').should.equal(false); + }); + + // '0.0' + it(`isUnPositiveInteger('0.0') === false`, function () { + isUnPositiveInteger('0.0').should.equal(false); + }); + + // '.' + it(`isUnPositiveInteger('.') === false`, function () { + isUnPositiveInteger('.').should.equal(false); + }); + // 0 it(`isUnPositiveInteger(0, {isStrict: true}) === true`, function () { isUnPositiveInteger(0, {isStrict: true}).should.equal(true); @@ -48,54 +142,69 @@ describe('isUnPositiveInteger test', function () { isUnPositiveInteger('0', {isStrict: true}).should.equal(false); }); + // -.3 + it(`isUnPositiveInteger(-.3) === false`, function () { + isUnPositiveInteger(-.3).should.equal(false); + }); + // -3 it(`isUnPositiveInteger(-3) === true`, function () { isUnPositiveInteger(-3).should.equal(true); }); - // '-3' - it(`isUnPositiveInteger('-3') === true`, function () { - isUnPositiveInteger('-3').should.equal(true); + // -3. + it(`isUnPositiveInteger(-3.) === true`, function () { + isUnPositiveInteger(-3.).should.equal(true); }); - // -3 - it(`isUnPositiveInteger(-3, {isStrict: true}) === true`, function () { - isUnPositiveInteger(-3, {isStrict: true}).should.equal(true); + // -3.3 + it(`isUnPositiveInteger(-3.3) === false`, function () { + isUnPositiveInteger(-3.3).should.equal(false); + }); + + // '-.3' + it(`isUnPositiveInteger('-.3') === false`, function () { + isUnPositiveInteger('-.3').should.equal(false); }); // '-3' - it(`isUnPositiveInteger('-3', {isStrict: true}) === false`, function () { - isUnPositiveInteger('-3', {isStrict: true}).should.equal(false); + it(`isUnPositiveInteger('-3') === true`, function () { + isUnPositiveInteger('-3').should.equal(true); }); - // 3.3 - it(`isUnPositiveInteger(3.3) === false`, function () { - isUnPositiveInteger(3.3).should.equal(false); + // '-3.' + it(`isUnPositiveInteger('-3.') === false`, function () { + isUnPositiveInteger('-3.').should.equal(false); }); - // '3.3' - it(`isUnPositiveInteger('3.3') === false`, function () { - isUnPositiveInteger('3.3').should.equal(false); + // '-3.3' + it(`isUnPositiveInteger('-3.3') === false`, function () { + isUnPositiveInteger('-3.3').should.equal(false); }); - // 3.3 - it(`isUnPositiveInteger(3.3, {isStrict: true}) === false`, function () { - isUnPositiveInteger(3.3, {isStrict: true}).should.equal(false); + // '--3' + it(`isUnPositiveInteger('--3') === false`, function () { + isUnPositiveInteger('--3').should.equal(false); }); - // '3.3' - it(`isUnPositiveInteger('3.3', {isStrict: true}) === false`, function () { - isUnPositiveInteger('3.3', {isStrict: true}).should.equal(false); + // '-3-3' + it(`isUnPositiveInteger('-3-3') === false`, function () { + isUnPositiveInteger('-3-3').should.equal(false); }); - // -3.3 - it(`isUnPositiveInteger(-3.3) === false`, function () { - isUnPositiveInteger(-3.3).should.equal(false); + // -.3 + it(`isUnPositiveInteger(-.3, {isStrict: true}) === false`, function () { + isUnPositiveInteger(-.3, {isStrict: true}).should.equal(false); }); - // '-3.3' - it(`isUnPositiveInteger('-3.3') === false`, function () { - isUnPositiveInteger('-3.3').should.equal(false); + // -3 + it(`isUnPositiveInteger(-3, {isStrict: true}) === true`, function () { + isUnPositiveInteger(-3, {isStrict: true}).should.equal(true); + }); + + // -3. + it(`isUnPositiveInteger(-3., {isStrict: true}) === true`, function () { + isUnPositiveInteger(-3., {isStrict: true}).should.equal(true); }); // -3.3 @@ -103,19 +212,24 @@ describe('isUnPositiveInteger test', function () { isUnPositiveInteger(-3.3, {isStrict: true}).should.equal(false); }); - // '-3.3' - it(`isUnPositiveInteger('-3.3', {isStrict: true}) === false`, function () { - isUnPositiveInteger('-3.3', {isStrict: true}).should.equal(false); + // '-.3' + it(`isUnPositiveInteger('-.3', {isStrict: true}) === false`, function () { + isUnPositiveInteger('-.3', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isUnPositiveInteger(Number.POSITIVE_INFINITY) === false`, function () { - isUnPositiveInteger(Number.POSITIVE_INFINITY).should.equal(false); + // '-3' + it(`isUnPositiveInteger('-3', {isStrict: true}) === false`, function () { + isUnPositiveInteger('-3', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isUnPositiveInteger(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function () { - isUnPositiveInteger(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + // '-3.' + it(`isUnPositiveInteger('-3.', {isStrict: true}) === false`, function () { + isUnPositiveInteger('-3.', {isStrict: true}).should.equal(false); + }); + + // '-3.3' + it(`isUnPositiveInteger('-3.3', {isStrict: true}) === false`, function () { + isUnPositiveInteger('-3.3', {isStrict: true}).should.equal(false); }); // '' @@ -152,4 +266,44 @@ describe('isUnPositiveInteger test', function () { it(`isUnPositiveInteger(-Infinity) === false`, function () { isUnPositiveInteger(Number.NEGATIVE_INFINITY).should.equal(false); }); + + // Object(3) + it(`isUnPositiveInteger(Object(3)) === false`, function () { + isUnPositiveInteger(Object(3)).should.equal(false); + }); + + // Object('3') + it(`isUnPositiveInteger(Object('3')) === false`, function () { + isUnPositiveInteger(Object('3')).should.equal(false); + }); + + // Object(3) + it(`isUnPositiveInteger(Object(3), {isStrict: true}) === false`, function () { + isUnPositiveInteger(Object(3), {isStrict: true}).should.equal(false); + }); + + // Object('3') + it(`isUnPositiveInteger(Object('3'), {isStrict: true}) === false`, function () { + isUnPositiveInteger(Object('3'), {isStrict: true}).should.equal(false); + }); + + // Object(-3) + it(`isUnPositiveInteger(Object(-3)) === true`, function () { + isUnPositiveInteger(Object(-3)).should.equal(true); + }); + + // Object('-3') + it(`isUnPositiveInteger(Object('-3')) === true`, function () { + isUnPositiveInteger(Object('-3')).should.equal(true); + }); + + // Object(-3) + it(`isUnPositiveInteger(Object(-3), {isStrict: true}) === true`, function () { + isUnPositiveInteger(Object(-3), {isStrict: true}).should.equal(true); + }); + + // Object('-3') + it(`isUnPositiveInteger(Object('-3'), {isStrict: true}) === false`, function () { + isUnPositiveInteger(Object('-3'), {isStrict: true}).should.equal(false); + }); }); diff --git a/test/isUnPositiveNumber.test.js b/test/isUnPositiveNumber.test.js index 4a561e1..e3b2a59 100644 --- a/test/isUnPositiveNumber.test.js +++ b/test/isUnPositiveNumber.test.js @@ -6,38 +6,267 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isUnPositiveNumber test', function () { +describe('isUnPositiveNumber', function () { + // -.3 + it(`isUnPositiveNumber(-.3) === true`, function () { + isUnPositiveNumber(-.3).should.equal(true); + }); + + // -0.3 + it(`isUnPositiveNumber(-0.3) === true`, function () { + isUnPositiveNumber(-0.3).should.equal(true); + }); + + // -0.35 + it(`isUnPositiveNumber(-0.35) === true`, function () { + isUnPositiveNumber(-0.35).should.equal(true); + }); + + // -0.356 + it(`isUnPositiveNumber(-0.356) === true`, function () { + isUnPositiveNumber(-0.356).should.equal(true); + }); + + // '-.3' + it(`isUnPositiveNumber('-.3') === true`, function () { + isUnPositiveNumber('-.3').should.equal(true); + }); + + // '-0.3' + it(`isPositiveNumber('-0.3') === true`, function () { + isUnPositiveNumber('-0.3').should.equal(true); + }); + + // '-0.35' + it(`isUnPositiveNumber('-0.35') === true`, function () { + isUnPositiveNumber('-0.35').should.equal(true); + }); + + // '-0.356' + it(`isUnPositiveNumber('-0.356') === true`, function () { + isUnPositiveNumber('-0.356').should.equal(true); + }); + + // '-00.356' + it(`isUnPositiveNumber('-00.356') === false`, function () { + isUnPositiveNumber('-00.356').should.equal(false); + }); + + // '-0.3.56' + it(`isUnPositiveNumber('-0.3.56') === false`, function () { + isUnPositiveNumber('-0.3.56').should.equal(false); + }); + + // '-0.356.' + it(`isUnPositiveNumber('-0.356.') === false`, function () { + isUnPositiveNumber('-0.356.').should.equal(false); + }); + + // -.3 + it(`isUnPositiveNumber(-.3, {isStrict: true}) === true`, function () { + isUnPositiveNumber(-.3, {isStrict: true}).should.equal(true); + }); + + // -0.3 + it(`isUnPositiveNumber(-0.3, {isStrict: true}) === true`, function () { + isUnPositiveNumber(-0.3, {isStrict: true}).should.equal(true); + }); + + // -0.35 + it(`isUnPositiveNumber(-0.35, {isStrict: true}) === true`, function () { + isUnPositiveNumber(-0.35, {isStrict: true}).should.equal(true); + }); + + // -0.356 + it(`isUnPositiveNumber(-0.356, {isStrict: true}) === true`, function () { + isUnPositiveNumber(-0.356, {isStrict: true}).should.equal(true); + }); + + // '-.3' + it(`isUnPositiveNumber('-.3', {isStrict: true}) === false`, function () { + isUnPositiveNumber('-.3', {isStrict: true}).should.equal(false); + }); + + // '-0.3' + it(`isUnPositiveNumber('-0.3', {isStrict: true}) === false`, function () { + isUnPositiveNumber('-0.3', {isStrict: true}).should.equal(false); + }); + + // '-0.35' + it(`isUnPositiveNumber('-0.35', {isStrict: true}) === false`, function () { + isUnPositiveNumber('-0.35', {isStrict: true}).should.equal(false); + }); + + // '-0.356' + it(`isUnPositiveNumber('-0.356', {isStrict: true}) === false`, function () { + isUnPositiveNumber('-0.356', {isStrict: true}).should.equal(false); + }); + // -3 it(`isUnPositiveNumber(-3) === true`, function () { isUnPositiveNumber(-3).should.equal(true); }); + // -3.5 + it(`isUnPositiveNumber(-3.5) === true`, function () { + isUnPositiveNumber(-3.5).should.equal(true); + }); + + // -3.56 + it(`isUnPositiveNumber(-3.56) === true`, function () { + isUnPositiveNumber(-3.56).should.equal(true); + }); + + // -30.56 + it(`isUnPositiveNumber(-30.56) === true`, function () { + isUnPositiveNumber(-30.56).should.equal(true); + }); + + // -30. + it(`isUnPositiveNumber(-30.) === true`, function () { + isUnPositiveNumber(-30.).should.equal(true); + }); + // '-3' it(`isUnPositiveNumber('-3') === true`, function () { isUnPositiveNumber('-3').should.equal(true); }); + // '-3.5' + it(`isUnPositiveNumber('-3.5') === true`, function () { + isUnPositiveNumber('-3.5').should.equal(true); + }); + + // '-3.56' + it(`isUnPositiveNumber('-3.56') === true`, function () { + isUnPositiveNumber('-3.56').should.equal(true); + }); + + // '-30.56' + it(`isUnPositiveNumber('-30.56') === true`, function () { + isUnPositiveNumber('-30.56').should.equal(true); + }); + + // '-30.' + it(`isUnPositiveNumber('-30.') === true`, function () { + isUnPositiveNumber('-30.').should.equal(true); + }); + + // '-30.5.6' + it(`isUnPositiveNumber('-30.5.6') === false`, function () { + isUnPositiveNumber('-30.5.6').should.equal(false); + }); + + // '-30.56.' + it(`isUnPositiveNumber('-30.56.') === false`, function () { + isUnPositiveNumber('-30.56.').should.equal(false); + }); + // -3 it(`isUnPositiveNumber(-3, {isStrict: true}) === true`, function () { isUnPositiveNumber(-3, {isStrict: true}).should.equal(true); }); + // -3.5 + it(`isUnPositiveNumber(-3.5, {isStrict: true}) === true`, function () { + isUnPositiveNumber(-3.5, {isStrict: true}).should.equal(true); + }); + + // -3.56 + it(`isUnPositiveNumber(-3.56, {isStrict: true}) === true`, function () { + isUnPositiveNumber(-3.56, {isStrict: true}).should.equal(true); + }); + + // -30.56 + it(`isUnPositiveNumber(-30.56, {isStrict: true}) === true`, function () { + isUnPositiveNumber(-30.56, {isStrict: true}).should.equal(true); + }); + + // -30. + it(`isUnPositiveNumber(-30., {isStrict: true}) === true`, function () { + isUnPositiveNumber(-30., {isStrict: true}).should.equal(true); + }); + // '-3' it(`isUnPositiveNumber('-3', {isStrict: true}) === false`, function () { isUnPositiveNumber('-3', {isStrict: true}).should.equal(false); }); + // '-3.5' + it(`isUnPositiveNumber('-3.5', {isStrict: true}) === false`, function () { + isUnPositiveNumber('-3.5', {isStrict: true}).should.equal(false); + }); + + // '-3.56' + it(`isUnPositiveNumber('-3.56', {isStrict: true}) === false`, function () { + isUnPositiveNumber('-3.56', {isStrict: true}).should.equal(false); + }); + + // '-30.56' + it(`isUnPositiveNumber('-30.56', {isStrict: true}) === false`, function () { + isUnPositiveNumber('-30.56', {isStrict: true}).should.equal(false); + }); + + // '-30.' + it(`isUnPositiveNumber('-30.', {isStrict: true}) === false`, function () { + isUnPositiveNumber('-30.', {isStrict: true}).should.equal(false); + }); + // 0 it(`isUnPositiveNumber(0) === true`, function () { isUnPositiveNumber(0).should.equal(true); }); + // +0 + it(`isUnPositiveNumber(+0) === true`, function () { + isUnPositiveNumber(+0).should.equal(true); + }); + + // -0 + it(`isUnPositiveNumber(-0) === true`, function () { + isUnPositiveNumber(-0).should.equal(true); + }); + + // 0. + it(`isUnPositiveNumber(0.) === true`, function () { + isUnPositiveNumber(0.).should.equal(true); + }); + + // .0 + it(`isUnPositiveNumber(.0) === true`, function () { + isUnPositiveNumber(.0).should.equal(true); + }); + // '0' it(`isUnPositiveNumber('0') === true`, function () { isUnPositiveNumber('0').should.equal(true); }); + // '+0' + it(`isUnPositiveNumber('+0') === true`, function () { + isUnPositiveNumber('+0').should.equal(true); + }); + + // '-0' + it(`isUnPositiveNumber('-0') === true`, function () { + isUnPositiveNumber('-0').should.equal(true); + }); + + // '0.' + it(`isUnPositiveNumber('0.') === true`, function () { + isUnPositiveNumber('0.').should.equal(true); + }); + + // '.' + it(`isUnPositiveNumber('.') === false`, function () { + isUnPositiveNumber('.').should.equal(false); + }); + + // '.0' + it(`isUnPositiveNumber('.0') === true`, function () { + isUnPositiveNumber('.0').should.equal(true); + }); + // 0 it(`isUnPositiveNumber(0, {isStrict: true}) === true`, function () { isUnPositiveNumber(0, {isStrict: true}).should.equal(true); @@ -48,34 +277,184 @@ describe('isUnPositiveNumber test', function () { isUnPositiveNumber('0', {isStrict: true}).should.equal(false); }); + // .3 + it(`isUnPositiveNumber(.3) === false`, function () { + isUnPositiveNumber(.3).should.equal(false); + }); + + // 0.3 + it(`isUnPositiveNumber(0.3) === false`, function () { + isUnPositiveNumber(0.3).should.equal(false); + }); + + // 0.35 + it(`isUnPositiveNumber(0.35) === false`, function () { + isUnPositiveNumber(0.35).should.equal(false); + }); + + // 0.356 + it(`isUnPositiveNumber(0.356) === false`, function () { + isUnPositiveNumber(0.356).should.equal(false); + }); + + // '.3' + it(`isUnPositiveNumber('.3') === false`, function () { + isUnPositiveNumber('.3').should.equal(false); + }); + + // '0.3' + it(`isUnPositiveNumber('0.3') === false`, function () { + isUnPositiveNumber('0.3').should.equal(false); + }); + + // '0.35' + it(`isUnPositiveNumber('0.35') === false`, function () { + isUnPositiveNumber('0.35').should.equal(false); + }); + + // '0.356' + it(`isUnPositiveNumber('0.356') === false`, function () { + isUnPositiveNumber('0.356').should.equal(false); + }); + + // .3 + it(`isUnPositiveNumber(.3, {isStrict: true}) === false`, function () { + isUnPositiveNumber(.3, {isStrict: true}).should.equal(false); + }); + + // 0.3 + it(`isUnPositiveNumber(0.3, {isStrict: true}) === false`, function () { + isUnPositiveNumber(0.3, {isStrict: true}).should.equal(false); + }); + + // 0.35 + it(`isUnPositiveNumber(0.35, {isStrict: true}) === false`, function () { + isUnPositiveNumber(0.35, {isStrict: true}).should.equal(false); + }); + + // 0.356 + it(`isUnPositiveNumber(0.356, {isStrict: true}) === false`, function () { + isUnPositiveNumber(0.356, {isStrict: true}).should.equal(false); + }); + + // '.3' + it(`isUnPositiveNumber('.3', {isStrict: true}) === false`, function () { + isUnPositiveNumber('.3', {isStrict: true}).should.equal(false); + }); + + // '0.3' + it(`isUnPositiveNumber('0.3', {isStrict: true}) === false`, function () { + isUnPositiveNumber('0.3', {isStrict: true}).should.equal(false); + }); + + // '0.35' + it(`isUnPositiveNumber('0.35', {isStrict: true}) === false`, function () { + isUnPositiveNumber('0.35', {isStrict: true}).should.equal(false); + }); + + // '0.356' + it(`isUnPositiveNumber('0.356', {isStrict: true}) === false`, function () { + isUnPositiveNumber('0.356', {isStrict: true}).should.equal(false); + }); + // 3 it(`isUnPositiveNumber(3) === false`, function () { isUnPositiveNumber(3).should.equal(false); }); + // 3.5 + it(`isUnPositiveNumber(3.5) === false`, function () { + isUnPositiveNumber(3.5).should.equal(false); + }); + + // 3.56 + it(`isUnPositiveNumber(3.56) === false`, function () { + isUnPositiveNumber(3.56).should.equal(false); + }); + + // 30.56 + it(`isUnPositiveNumber(30.56) === false`, function () { + isUnPositiveNumber(30.56).should.equal(false); + }); + + // 30. + it(`isUnPositiveNumber(30.) === false`, function () { + isUnPositiveNumber(30.).should.equal(false); + }); + // '3' it(`isUnPositiveNumber('3') === false`, function () { isUnPositiveNumber('3').should.equal(false); }); + // '3.5' + it(`isUnPositiveNumber('3.5') === false`, function () { + isUnPositiveNumber('3.5').should.equal(false); + }); + + // '3.56' + it(`isUnPositiveNumber('3.56') === false`, function () { + isUnPositiveNumber('3.56').should.equal(false); + }); + + // '30.56' + it(`isUnPositiveNumber('30.56') === false`, function () { + isUnPositiveNumber('30.56').should.equal(false); + }); + + // '30.' + it(`isUnPositiveNumber('30.') === false`, function () { + isUnPositiveNumber('30.').should.equal(false); + }); + // 3 it(`isUnPositiveNumber(3, {isStrict: true}) === false`, function () { isUnPositiveNumber(3, {isStrict: true}).should.equal(false); }); + // 3.5 + it(`isUnPositiveNumber(3.5, {isStrict: true}) === false`, function () { + isUnPositiveNumber(3.5, {isStrict: true}).should.equal(false); + }); + + // 3.56 + it(`isUnPositiveNumber(3.56, {isStrict: true}) === false`, function () { + isUnPositiveNumber(3.56, {isStrict: true}).should.equal(false); + }); + + // 30.56 + it(`isUnPositiveNumber(30.56, {isStrict: true}) === false`, function () { + isUnPositiveNumber(30.56, {isStrict: true}).should.equal(false); + }); + + // 30. + it(`isUnPositiveNumber(30., {isStrict: true}) === false`, function () { + isUnPositiveNumber(30., {isStrict: true}).should.equal(false); + }); + // '3' it(`isUnPositiveNumber('3', {isStrict: true}) === false`, function () { isUnPositiveNumber('3', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isUnPositiveNumber(Number.POSITIVE_INFINITY) === false`, function () { - isUnPositiveNumber(Number.POSITIVE_INFINITY).should.equal(false); + // '3.5' + it(`isUnPositiveNumber('3.5', {isStrict: true}) === false`, function () { + isUnPositiveNumber('3.5', {isStrict: true}).should.equal(false); + }); + + // '3.56' + it(`isUnPositiveNumber('3.56', {isStrict: true}) === false`, function () { + isUnPositiveNumber('3.56', {isStrict: true}).should.equal(false); }); - // Number.POSITIVE_INFINITY - it(`isUnPositiveNumber(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function () { - isUnPositiveNumber(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + // '30.56' + it(`isUnPositiveNumber('30.56', {isStrict: true}) === false`, function () { + isUnPositiveNumber('30.56', {isStrict: true}).should.equal(false); + }); + + // '30.' + it(`isUnPositiveNumber('30.', {isStrict: true}) === false`, function () { + isUnPositiveNumber('30.', {isStrict: true}).should.equal(false); }); // '' @@ -112,4 +491,24 @@ describe('isUnPositiveNumber test', function () { it(`isUnPositiveNumber(-Infinity) === false`, function () { isUnPositiveNumber(Number.NEGATIVE_INFINITY).should.equal(false); }); + + // Object(-3.56) + it(`isUnPositiveNumber(Object(-3.56)) === true`, function () { + isUnPositiveNumber(Object(-3.56)).should.equal(true); + }); + + // Object('-3.56') + it(`isUnPositiveNumber(Object('-3.56')) === true`, function () { + isUnPositiveNumber(Object('-3.56')).should.equal(true); + }); + + // Object(-3.56) + it(`isUnPositiveNumber(Object(-3.56), {isStrict: true}) === true`, function () { + isUnPositiveNumber(Object(-3.56), {isStrict: true}).should.equal(true); + }); + + // Object('-3.56') + it(`isUnPositiveNumber(Object('-3.56'), {isStrict: true}) === false`, function () { + isUnPositiveNumber(Object('-3.56'), {isStrict: true}).should.equal(false); + }); }); diff --git a/test/isUnZero.test.js b/test/isUnZero.test.js index c4fcb2b..8b24da6 100644 --- a/test/isUnZero.test.js +++ b/test/isUnZero.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isUnZero test', function () { +describe('isUnZero', function () { // 3 it(`isUnZero(3) === true`, function () { isUnZero(3).should.equal(true); @@ -23,6 +22,16 @@ describe('isUnZero test', function () { isUnZero('3').should.equal(true); }); + // 3 + it(`isUnZero(3, {isStrict: true}) === true`, function () { + isUnZero(3, {isStrict: true}).should.equal(true); + }); + + // -3 + it(`isUnZero(-3, {isStrict: true}) === true`, function () { + isUnZero(-3, {isStrict: true}).should.equal(true); + }); + // '3' it(`isUnZero('3', {isStrict: true}) === false`, function () { isUnZero('3', {isStrict: true}).should.equal(false); @@ -36,6 +45,10 @@ describe('isUnZero test', function () { isUnZero('0').should.equal(false); }); + it(`isUnZero(0, {isStrict: true}) === false`, function () { + isUnZero(0, {isStrict: true}).should.equal(false); + }); + it(`isUnZero('0', {isStrict: true}) === false`, function () { isUnZero('0', {isStrict: true}).should.equal(false); }); @@ -75,29 +88,24 @@ describe('isUnZero test', function () { isUnZero(undefined).should.equal(false); }); - // Number(0) - it(`isUnZero(Number(0)) === false`, function () { - isUnZero(Number(0)).should.equal(false); - }); - - // Number(3) - it(`isUnZero(Number(3)) === true`, function () { - isUnZero(Number(3)).should.equal(true); + // Object(0) + it(`isUnZero(Object(0)) === false`, function () { + isUnZero(Object(0)).should.equal(false); }); - // new Number(0) - it(`isUnZero(new Number(0)) === false`, function () { - isUnZero(new Number(0)).should.equal(false); + // Object('0') + it(`isUnZero(Object('0')) === false`, function () { + isUnZero(Object('0')).should.equal(false); }); - // new Number('0') - it(`isUnZero(new Number(0)) === false`, function () { - isUnZero(new Number('0')).should.equal(false); + // Object(0) + it(`isUnZero(Object(0), {isStrict: true}) === false`, function () { + isUnZero(Object(0), {isStrict: true}).should.equal(false); }); - // new Number(3) - it(`isUnZero(new Number(3)) === true`, function () { - isUnZero(new Number(3)).should.equal(true); + // Object('0') + it(`isUnZero(Object('0'), {isStrict: true}) === false`, function () { + isUnZero(Object('0'), {isStrict: true}).should.equal(false); }); // Object(3) @@ -110,6 +118,11 @@ describe('isUnZero test', function () { isUnZero(Object('3')).should.equal(true); }); + // Object(3) + it(`isUnZero(Object(3), {isStrict: true}) === false`, function () { + isUnZero(Object(3), {isStrict: true}).should.equal(true); + }); + // Object('3') it(`isUnZero(Object('3'), {isStrict: true}) === false`, function () { isUnZero(Object('3'), {isStrict: true}).should.equal(false); diff --git a/test/isUndefined.test.js b/test/isUndefined.test.js index 98d5826..0ec972a 100644 --- a/test/isUndefined.test.js +++ b/test/isUndefined.test.js @@ -6,8 +6,7 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isUndefined test', function () { +describe('isUndefined', function () { // undefined it(`isUndefined(undefined) === true`, function () { isUndefined(undefined).should.equal(true); diff --git a/test/isZero.test.js b/test/isZero.test.js index be679b0..9665751 100644 --- a/test/isZero.test.js +++ b/test/isZero.test.js @@ -6,26 +6,83 @@ const should = chai.should; chai.use(require('chai-things')); should(); -// Test -describe('isZero test', function () { +describe('isZero', function () { // 3 it(`isZero(3) === false`, function () { isZero(3).should.equal(false); }); // -3 - it(`isZero(3) === false`, function () { - isZero(3).should.equal(false); + it(`isZero(-3) === false`, function () { + isZero(-3).should.equal(false); + }); + + // '3' + it(`isZero('3') === false`, function () { + isZero('3').should.equal(false); + }); + + // '-3' + it(`isZero('-3') === false`, function () { + isZero('-3').should.equal(false); + }); + + // 3 + it(`isZero(3, {isStrict: true}) === false`, function () { + isZero(3, {isStrict: true}).should.equal(false); }); + // -3 + it(`isZero(-3, {isStrict: true}) === false`, function () { + isZero(-3, {isStrict: true}).should.equal(false); + }); + + // '3' + it(`isZero('3', {isStrict: true}) === false`, function () { + isZero('3', {isStrict: true}).should.equal(false); + }); + + // '-3' + it(`isZero('-3', {isStrict: true}) === false`, function () { + isZero('-3', {isStrict: true}).should.equal(false); + }); + + // 0 it(`isZero(0) === true`, function () { isZero(0).should.equal(true); }); + // '0' it(`isZero('0') === true`, function () { isZero('0').should.equal(true); }); + // '0.0' + it(`isZero('0.0') === true`, function () { + isZero('0.0').should.equal(true); + }); + + // '0.' + it(`isZero('0.') === true`, function () { + isZero('0.').should.equal(true); + }); + + // '.0' + it(`isZero('.0') === true`, function () { + isZero('.0').should.equal(true); + }); + + // '.' + it(`isZero('.') === false`, function () { + isZero('.').should.equal(false); + }); + + // 0 + it(`isZero(0, {isStrict: true}) === true`, function () { + isZero(0, {isStrict: true}).should.equal(true); + }); + + // '0' it(`isZero('0', {isStrict: true}) === false`, function () { isZero('0', {isStrict: true}).should.equal(false); }); @@ -65,21 +122,6 @@ describe('isZero test', function () { isZero(undefined).should.equal(false); }); - // Number(0) - it(`isZero(Number(0)) === true`, function () { - isZero(Number(0)).should.equal(true); - }); - - // new Number(0) - it(`isZero(new Number(0)) === true`, function () { - isZero(new Number(0)).should.equal(true); - }); - - // new Number('0') - it(`isZero(new Number(0)) === true`, function () { - isZero(new Number('0')).should.equal(true); - }); - // Object(0) it(`isZero(Object(0)) === true`, function () { isZero(Object(0)).should.equal(true); @@ -90,6 +132,11 @@ describe('isZero test', function () { isZero(Object('0')).should.equal(true); }); + // Object(0) + it(`isZero(Object(0), {isStrict: true}) === true`, function () { + isZero(Object(0), {isStrict: true}).should.equal(true); + }); + // Object('0') it(`isZero(Object('0'), {isStrict: true}) === false`, function () { isZero(Object('0'), {isStrict: true}).should.equal(false); diff --git a/validator.js b/validator.js index 1effbd6..22b55ba 100644 --- a/validator.js +++ b/validator.js @@ -70,7 +70,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 17); +/******/ return __webpack_require__(__webpack_require__.s = 20); /******/ }) /************************************************************************/ /******/ ([ @@ -107,18 +107,21 @@ module.exports = _isObject; // 正则表达式 var REGEX_ENUM = { + // POSITIVE_NUMBER_REX: /^[1-9]\d*((\.\d+))?$|^0?\.\d*[1-9]\d*$/, // 正数 + POSITIVE_NUMBER_REX: /^[1-9]\d*(\.\d*)?$|^0?\.\d*[1-9]\d*$/, // 正数 + NEGATIVE_NUMBER_REX: /^-[1-9]\d*(\.\d*)?$|^-0?\.\d*[1-9]\d*$/, // 负数 + // UN_POSITIVE_NUMBER_REX: /^-[1-9]\d*(\.\d*)?$|^-0?\.\d*[1-9]\d*$|^0*(.)?0*$/, // 非正数 + // UN_NEGATIVE_NUMBER_REX: /^[1-9]\d*(\.\d*)?$|^0?\.\d*[1-9]\d*$|^0*(.)?0*$/, // 非负数 + INTEGER_REX: /^-?\d+$/, // 整数 POSITIVE_INTEGER_REX: /^[1-9]\d*$/, // 正整数 NEGATIVE_INTEGER_REX: /^-[1-9]\d*$/, // 负整数 UN_POSITIVE_INTEGER_REX: /^-[1-9]\d*$|^0$/, // 非正整数 UN_NEGATIVE_INTEGER_REX: /^[1-9]\d*$|^0$/, // 非负整数 - POSITIVE_NUMBER_REX: /^[1-9]\d*(\.\d)*$|^0\.\d*[1-9]\d*$/, // 正数 - NEGATIVE_NUMBER_REX: /^-[1-9]\d*(\.\d)*$|^-0\.\d*[1-9]\d*$/, // 负数 - UN_NEGATIVE_NUMBER_REX: /^[1-9]\d*(\.\d)*$|^0\.\d*[1-9]\d*$|^0$/, // 非负数 - UN_POSITIVE_NUMBER_REX: /^-[1-9]\d*(\.\d)*$|^-0\.\d*[1-9]\d*$|^0$/, // 非正数 + LEFT_WHITE_SPACE_REX: /^\s\s*/, // 左空白 + RIGHT_WHITE_SPACE_REX: /\s\s*$/, // 右空白 - EMAIL_REX: /^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/, // 邮箱 TELEPHONE_REX: { // 座机 'zh-CN': /^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/ }, @@ -126,6 +129,9 @@ var REGEX_ENUM = { 'zh-CN': /^(\+?0?86-?)?1\d{10}$/ }, + // 邮箱 + EMAIL_REX: /^[a-zA-Z0-9]+([._\\-]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/, + // ipv4 IPV4_REX: /\b((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])\.((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])\.((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])\.((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])\b/ }; @@ -194,7 +200,7 @@ module.exports = _isString; /***/ (function(module, exports) { -// Js数据类型 +// Js 数据类型 var DATA_TYPE_ENUM = {}; // 存储类型 @@ -285,10 +291,10 @@ module.exports = _assertDataType; /***/ (function(module, exports, __webpack_require__) { -var _isNaN = __webpack_require__(7); +var _isNaN = __webpack_require__(8); var _isNumber = __webpack_require__(2); var _isObject = __webpack_require__(0); -var _isUnEmptyString = __webpack_require__(9); +var _isUnEmptyString = __webpack_require__(10); /** * 校验参数 `val` 是否为实数(有理数和无理数) @@ -325,7 +331,7 @@ function _isRealNumber(val, options) { return !_isNaN(val); } - // 若是非严格模式, 则对字符串 '3' 进行判定, 需要排除 ' ' 字符串 + // 若是非严格模式, 则对字符串 '3' 进行判定, 需要排除 '', ' ' 字符串 if (opts.isStrict !== true && _isUnEmptyString(val, {isStrict: true})) { var detal = val - 0; @@ -340,6 +346,60 @@ module.exports = _isRealNumber; /***/ }), /* 7 */ +/***/ (function(module, exports, __webpack_require__) { + + +var _isObject = __webpack_require__(0); +var _isNumber = __webpack_require__(2); +var _isRealNumber = __webpack_require__(6); + +/** + * 校验参数 `val` 是否为零 + * + * 该接口存在两种模式, 即严格模式、非严格模式; + * + * 默认采用 `非严格模式` + * + * 若参数 `val` 为 number 类型, 并且等于零, 则返回 true, 否则返回 false + * 若参数 `val` 为 string 类型, 并且经过 ToNumber 转换后的数据等于零, 则返回 true, 否则返回 false + * 若参数 `val` 不属于以上两种类型, 则直接返回 false + * + * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + * + * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false + * + * e.g. + * + * 待校验参数 '0' + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true + * + * @param {*} val 待校验的参数 + * @param {Object} options 可选参数 + * @param {Boolean} options.isStrict 是否严格模式 + * @return {Boolean} 返回校验结果 + * @version 0.0.7 + * @since 0.0.4 + */ +function _isZero(val, options) { + var opts = _isObject(options) ? options : {}; + + if (_isNumber(val)) { + return val - 0 === 0; + } + + if (opts.isStrict !== true) { + return _isRealNumber(val) && val - 0 === 0; + } + + return false; +} + +module.exports = _isZero; + + +/***/ }), +/* 8 */ /***/ (function(module, exports) { @@ -355,7 +415,6 @@ module.exports = _isRealNumber; */ function _isNaN(val) { // @TODO - // // 引用: ECMAScript5.1 15章节 [15.1.2.4](https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.2.4) // 全局对象函数 isNaN 存在如下怪异行为: 它总是先将参数转化成数字,然后再来判断是否是 NaN // 因此,会导致问题: @@ -363,11 +422,13 @@ function _isNaN(val) { // <=> isNaN(Number('foo')); // => true // // 解决方案: 使用 `!==`, NaN 是唯一一个不与自身恒等 + // 引用: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/NaN + // + // 从 ES6 开始,Number 提供了 Number.isNaN 来判断是否为 NaN // - // 从ES6开始,Number提供了 Number.isNaN 来判断是否为 NaN - // e.g: - // Number.isNaN('foo'); // => false - // Number.isNaN(NaN); // => true + // e.g. + // Number.isNaN('foo'); // => false + // Number.isNaN(NaN); // => true // return val !== val; } @@ -376,7 +437,7 @@ module.exports = _isNaN; /***/ }), -/* 8 */ +/* 9 */ /***/ (function(module, exports) { @@ -402,7 +463,7 @@ module.exports = _isInfinity; /***/ }), -/* 9 */ +/* 10 */ /***/ (function(module, exports, __webpack_require__) { @@ -431,8 +492,8 @@ var _isObject = __webpack_require__(0); * @param {*} val 待校验的参数 * @param {Object} options 可选参数 * @param {Boolean} options.isStrict 是否严格模式 - * @return {Boolean} 返回校验结果 - * @version 0.0.5 + * @return {Booean} 返回校验结果 + * @version 0.0.7 * @since 0.0.4 */ function _isUnEmptyString(val, options) { @@ -442,19 +503,27 @@ function _isUnEmptyString(val, options) { return false; } - return opts.isStrict === false ? val !== '' : (val.trim() !== ''); + if (opts.isStrict === false) { + return val !== ''; + } + + // @TODO + // 引用: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim + // String.prototype.trim, 在 ECMAScript 5.1 定义, 在 JavaScript 1.8.1 实现 + // return val.replace(REGEX_ENUM.LEFT_WHITE_SPACE_REX, '').replace(REGEX_ENUM.RIGHT_WHITE_SPACE_REX, '') !== ''; + return val.trim() !== ''; } module.exports = _isUnEmptyString; /***/ }), -/* 10 */ +/* 11 */ /***/ (function(module, exports, __webpack_require__) { var _isRealNumber = __webpack_require__(6); -var _isInfinity = __webpack_require__(8); +var _isInfinity = __webpack_require__(9); /** * 校验参数 `val` 是否为数字 @@ -492,7 +561,107 @@ module.exports = _isNumeric; /***/ }), -/* 11 */ +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + + +var _isNumber = __webpack_require__(2); +var _isObject = __webpack_require__(0); +var REGEX_ENUM = __webpack_require__(1); + +/** + * 校验参数 `val` 是否为 正数 + * + * 该接口存在两种模式, 即严格模式、非严格模式 + * + * 默认采用 `非严格模式` + * + * 若参数 `val` 为 number 类型, 并且是正数 则返回 true, 否则返回 false + * 若参数 `val` 为 string 类型, 并且通过验证为正数字符串, 则返回 true, 否则返回 false + * 若参数 `val` 不属于以上两种类型, 则直接返回 false + * + * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + * + * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false + * + * e.g. + * + * 待校验参数 '3' + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true + * + * @param {*} val 待校验的参数 + * @param {Object} options 可选参数 + * @param {Boolean} options.isStrict 是否严格模式 + * @return {Boolean} 返回校验结果 + * @version 0.0.7 + * @since 0.0.4 + */ +function _isPositiveNumber(val, options) { + var opts = _isObject(options) ? options : {}; + + if (opts.isStrict === true) { + return _isNumber(val) && REGEX_ENUM.POSITIVE_NUMBER_REX.test(val); + } + + return REGEX_ENUM.POSITIVE_NUMBER_REX.test(val); +} + +module.exports = _isPositiveNumber; + + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { + + +var _isNumber = __webpack_require__(2); +var _isObject = __webpack_require__(0); +var REGEX_ENUM = __webpack_require__(1); + +/** + * 校验参数 `val` 是否为负数 + * + * 该接口存在两种模式, 即严格模式、非严格模式; + * + * 默认采用 `非严格模式` + * + * 若参数 `val` 为 number 类型, 并且是负数 则返回 true, 否则返回 false + * 若参数 `val` 为 string 类型, 并且通过验证为负数字符串, 则返回 true, 否则返回 false + * 若参数 `val` 不属于以上两种类型, 则直接返回 false + * + * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + * + * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false + * + * e.g. + * + * 待校验参数 '-3' + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true + * + * @param {*} val 待校验的参数 + * @param {Object} options 可选参数 + * @param {Boolean} options.isStrict 是否严格模式 + * @return {Boolean} 返回校验结果 + * @version 0.0.7 + * @since 0.0.4 + */ +function _isNegativeNumber(val, options) { + var opts = _isObject(options) ? options : {}; + + if (opts.isStrict === true) { + return _isNumber(val) && REGEX_ENUM.NEGATIVE_NUMBER_REX.test(val); + } + + return REGEX_ENUM.NEGATIVE_NUMBER_REX.test(val); +} + +module.exports = _isNegativeNumber; + + +/***/ }), +/* 14 */ /***/ (function(module, exports, __webpack_require__) { @@ -519,12 +688,12 @@ module.exports = _isArray; /***/ }), -/* 12 */ +/* 15 */ /***/ (function(module, exports, __webpack_require__) { var _isObject = __webpack_require__(0); -var _isFunction = __webpack_require__(13); +var _isFunction = __webpack_require__(16); /** * 校验参数 `val` 是否为纯粹的 object @@ -556,7 +725,7 @@ module.exports = _isPlainObject; /***/ }), -/* 13 */ +/* 16 */ /***/ (function(module, exports, __webpack_require__) { @@ -583,12 +752,12 @@ module.exports = _isFunction; /***/ }), -/* 14 */ +/* 17 */ /***/ (function(module, exports, __webpack_require__) { var _isString = __webpack_require__(3); -var LOCALE_ENUM = __webpack_require__(15); +var LOCALE_ENUM = __webpack_require__(18); var REGEX_ENUM = __webpack_require__(1); /** @@ -627,7 +796,7 @@ module.exports = _isMobile; /***/ }), -/* 15 */ +/* 18 */ /***/ (function(module, exports) { @@ -640,12 +809,12 @@ module.exports = LOCALE_TYPE_ENUM; /***/ }), -/* 16 */ +/* 19 */ /***/ (function(module, exports, __webpack_require__) { var _isString = __webpack_require__(3); -var LOCALE_ENUM = __webpack_require__(15); +var LOCALE_ENUM = __webpack_require__(18); var REGEX_ENUM = __webpack_require__(1); /** @@ -684,28 +853,28 @@ module.exports = _isTelephone; /***/ }), -/* 17 */ +/* 20 */ /***/ (function(module, exports, __webpack_require__) { -var _isUndefined = __webpack_require__(18); -var _isNull = __webpack_require__(19); -var _isNil = __webpack_require__(20); +var _isUndefined = __webpack_require__(21); +var _isNull = __webpack_require__(22); +var _isNil = __webpack_require__(23); -var _isBoolean = __webpack_require__(21); +var _isBoolean = __webpack_require__(24); -var _isNaN = __webpack_require__(7); -var _isInfinity = __webpack_require__(8); +var _isNaN = __webpack_require__(8); +var _isInfinity = __webpack_require__(9); var _isNumber = __webpack_require__(2); var _isRealNumber = __webpack_require__(6); -var _isNumeric = __webpack_require__(10); +var _isNumeric = __webpack_require__(11); -var _isZero = __webpack_require__(22); -var _isUnZero = __webpack_require__(23); +var _isZero = __webpack_require__(7); +var _isUnZero = __webpack_require__(25); -var _isPositiveNumber = __webpack_require__(24); -var _isNegativeNumber = __webpack_require__(25); +var _isPositiveNumber = __webpack_require__(12); +var _isNegativeNumber = __webpack_require__(13); var _isUnPositiveNumber = __webpack_require__(26); var _isUnNegativeNumber = __webpack_require__(27); @@ -717,20 +886,20 @@ var _isUnNegativeInteger = __webpack_require__(32); var _isString = __webpack_require__(3); var _isEmptyString = __webpack_require__(33); -var _isUnEmptyString = __webpack_require__(9); +var _isUnEmptyString = __webpack_require__(10); -var _isArray = __webpack_require__(11); +var _isArray = __webpack_require__(14); var _isEmptyArray = __webpack_require__(34); var _isObject = __webpack_require__(0); -var _isPlainObject = __webpack_require__(12); +var _isPlainObject = __webpack_require__(15); var _isJSON = __webpack_require__(35); -var _isFunction = __webpack_require__(13); +var _isFunction = __webpack_require__(16); -var _isMobile = __webpack_require__(14); -var _isTelephone = __webpack_require__(16); +var _isMobile = __webpack_require__(17); +var _isTelephone = __webpack_require__(19); var _isPhone = __webpack_require__(36); var _isEmail = __webpack_require__(37); @@ -790,7 +959,7 @@ module.exports = { /***/ }), -/* 18 */ +/* 21 */ /***/ (function(module, exports) { @@ -814,7 +983,7 @@ module.exports = _isUndefined; /***/ }), -/* 19 */ +/* 22 */ /***/ (function(module, exports) { @@ -838,7 +1007,7 @@ module.exports = _isNull; /***/ }), -/* 20 */ +/* 23 */ /***/ (function(module, exports) { @@ -863,7 +1032,7 @@ module.exports = _isNil; /***/ }), -/* 21 */ +/* 24 */ /***/ (function(module, exports, __webpack_require__) { @@ -890,60 +1059,11 @@ module.exports = _isBoolean; /***/ }), -/* 22 */ -/***/ (function(module, exports, __webpack_require__) { - - -var _isObject = __webpack_require__(0); -var _isRealNumber = __webpack_require__(6); - -/** - * 校验参数 `val` 是否为零 - * - * 该接口存在两种模式, 即严格模式、非严格模式; - * - * 默认采用 `非严格模式` - * - * 若参数 `val` 为 number 类型, 并且等于零, 则返回 true, 否则返回 false - * 若参数 `val` 为 string 类型, 并且经过 ToNumber 转换后的数据等于零, 则返回 true, 否则返回 false - * 若参数 `val` 不属于以上两种类型, 则直接返回 false - * - * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false - * - * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false - * - * e.g. - * - * 待校验参数 '0' - * > 若是严格模式, 则该参数值校验后, 返回 false - * > 若是非严格模式, 则该参数值校验后, 返回 true - * - * @param {*} val 待校验的参数 - * @param {Object} options 可选参数 - * @param {Boolean} options.isStrict 是否严格模式 - * @return {Boolean} 返回校验结果 - * @version 0.0.5 - * @since 0.0.4 - */ -function _isZero(val, options) { - var opts = _isObject(options) ? options : {}; - - if (opts.isStrict === true) { - return val === 0; - } - - return _isRealNumber(val) && val - 0 === 0; -} - -module.exports = _isZero; - - -/***/ }), -/* 23 */ +/* 25 */ /***/ (function(module, exports, __webpack_require__) { -var _isNumeric = __webpack_require__(10); +var _isNumeric = __webpack_require__(11); /** * 校验参数 `val` 是否为 number, 并且不等于零 @@ -980,114 +1100,13 @@ function _isUnZero(val, options) { module.exports = _isUnZero; -/***/ }), -/* 24 */ -/***/ (function(module, exports, __webpack_require__) { - - -var _isNumber = __webpack_require__(2); -var _isObject = __webpack_require__(0); -var REGEX_ENUM = __webpack_require__(1); - -/** - * 校验参数 `val` 是否为 正数 - * - * 该接口存在两种模式, 即严格模式、非严格模式 - * - * 默认采用 `非严格模式` - * - * 若参数 `val` 为 number 类型, 并且是正数 则返回 true, 否则返回 false - * 若参数 `val` 为 string 类型, 并且通过验证为正数字符串, 则返回 true, 否则返回 false - * 若参数 `val` 不属于以上两种类型, 则直接返回 false - * - * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false - * - * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false - * - * e.g. - * - * 待校验参数 '3' - * > 若是严格模式, 则该参数值校验后, 返回 false - * > 若是非严格模式, 则该参数值校验后, 返回 true - * - * @param {*} val 待校验的参数 - * @param {Object} options 可选参数 - * @param {Boolean} options.isStrict 是否严格模式 - * @return {Boolean} 返回校验结果 - * @version 0.0.5 - * @since 0.0.4 - */ -function _isPositiveNumber(val, options) { - var opts = _isObject(options) ? options : {}; - - if (opts.isStrict === true) { - return _isNumber(val) && REGEX_ENUM.POSITIVE_NUMBER_REX.test(val); - } - - return REGEX_ENUM.POSITIVE_NUMBER_REX.test(val); -} - -module.exports = _isPositiveNumber; - - -/***/ }), -/* 25 */ -/***/ (function(module, exports, __webpack_require__) { - - -var _isNumber = __webpack_require__(2); -var _isObject = __webpack_require__(0); -var REGEX_ENUM = __webpack_require__(1); - -/** - * 校验参数 `val` 是否为负数 - * - * 该接口存在两种模式, 即严格模式、非严格模式; - * - * 默认采用 `非严格模式` - * - * 若参数 `val` 为 number 类型, 并且是负数 则返回 true, 否则返回 false - * 若参数 `val` 为 string 类型, 并且通过验证为负数字符串, 则返回 true, 否则返回 false - * 若参数 `val` 不属于以上两种类型, 则直接返回 false - * - * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false - * - * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false - * - * e.g. - * - * 待校验参数 '-3' - * > 若是严格模式, 则该参数值校验后, 返回 false - * > 若是非严格模式, 则该参数值校验后, 返回 true - * - * @param {*} val 待校验的参数 - * @param {Object} options 可选参数 - * @param {Boolean} options.isStrict 是否严格模式 - * @return {Boolean} 返回校验结果 - * @version 0.0.5 - * @since 0.0.4 - */ -function _isNegativeNumber(val, options) { - var opts = _isObject(options) ? options : {}; - - if (opts.isStrict === true) { - return _isNumber(val) && REGEX_ENUM.NEGATIVE_NUMBER_REX.test(val); - } - - return REGEX_ENUM.NEGATIVE_NUMBER_REX.test(val); -} - -module.exports = _isNegativeNumber; - - /***/ }), /* 26 */ /***/ (function(module, exports, __webpack_require__) { -var _isNumber = __webpack_require__(2); -var _isObject = __webpack_require__(0); -var REGEX_ENUM = __webpack_require__(1); +var _isZero = __webpack_require__(7); +var _isNegativeNumber = __webpack_require__(13); /** * 校验参数 `val` 是否为非正数, 即负数和零 @@ -1114,17 +1133,11 @@ var REGEX_ENUM = __webpack_require__(1); * @param {Object} options 可选参数 * @param {Boolean} options.isStrict 是否严格模式 * @return {Boolean} 返回校验结果 - * @version 0.0.5 + * @version 0.0.7 * @since 0.0.4 */ function _isUnPositiveNumber(val, options) { - var opts = _isObject(options) ? options : {}; - - if (opts.isStrict === true) { - return _isNumber(val) && REGEX_ENUM.UN_POSITIVE_NUMBER_REX.test(val); - } - - return REGEX_ENUM.UN_POSITIVE_NUMBER_REX.test(val); + return _isNegativeNumber(val, options) || _isZero(val, options); } module.exports = _isUnPositiveNumber; @@ -1135,9 +1148,8 @@ module.exports = _isUnPositiveNumber; /***/ (function(module, exports, __webpack_require__) { -var _isNumber = __webpack_require__(2); -var _isObject = __webpack_require__(0); -var REGEX_ENUM = __webpack_require__(1); +var _isZero = __webpack_require__(7); +var _isPositiveNumber = __webpack_require__(12); /** * 校验参数 `val` 是否为非负数, 即正数和零 @@ -1164,17 +1176,11 @@ var REGEX_ENUM = __webpack_require__(1); * @param {Object} options 可选参数 * @param {Boolean} options.isStrict 是否严格模式 * @return {Boolean} 返回校验结果 - * @version 0.0.5 + * @version 0.0.7 * @since 0.0.4 */ function _isUnNegativeNumber(val, options) { - var opts = _isObject(options) ? options : {}; - - if (opts.isStrict === true) { - return _isNumber(val) && REGEX_ENUM.UN_NEGATIVE_NUMBER_REX.test(val); - } - - return REGEX_ENUM.UN_NEGATIVE_NUMBER_REX.test(val); + return _isPositiveNumber(val, options) || _isZero(val, options); } module.exports = _isUnNegativeNumber; @@ -1448,8 +1454,7 @@ var _isObject = __webpack_require__(0); * 若参数 `val` 不是 string, 则直接返回 false * 若参数 `val` 是 string, 并且为空,则返回 true, 否则, 返回 false * - * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, - * 则会对参数 `val` 进行两端去除空白(空字符),之后在校验其是否为空字符串 + * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则会对参数 `val` 进行两端去除空白(空字符),之后在校验其是否为空字符串 * * e.g. * @@ -1461,7 +1466,7 @@ var _isObject = __webpack_require__(0); * @param {Object} options 可选参数 * @param {Boolean} options.isStrict 是否严格模式 * @return {Boolean} 返回校验结果 - * @version 0.0.5 + * @version 0.0.7 * @since 0.0.5 */ function _isEmptyString(val, options) { @@ -1471,7 +1476,15 @@ function _isEmptyString(val, options) { return false; } - return opts.isStrict === false ? val === '' : (val.trim() === ''); + if (opts.isStrict === false) { + return val === ''; + } + + // @TODO + // 引用: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim + // String.prototype.trim, 在 ECMAScript 5.1 定义, 在 JavaScript 1.8.1 实现 + // return val.replace(REGEX_ENUM.LEFT_WHITE_SPACE_REX, '').replace(REGEX_ENUM.RIGHT_WHITE_SPACE_REX, '') === ''; + return val.trim() === ''; } module.exports = _isEmptyString; @@ -1482,7 +1495,7 @@ module.exports = _isEmptyString; /***/ (function(module, exports, __webpack_require__) { -var _isArray = __webpack_require__(11); +var _isArray = __webpack_require__(14); /** * 校验参数 `val` 是否为空数组 @@ -1512,7 +1525,7 @@ module.exports = _isEmptyArray; var _isString = __webpack_require__(3); -var _isPlainObject = __webpack_require__(12); +var _isPlainObject = __webpack_require__(15); /** * 校验参数 `val` 是否为 JSON 对象 @@ -1530,6 +1543,9 @@ function _isJSON(val) { } try { + // @TODO + // 引用: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse + // JSON support, 在 ECMAScript 5.1 定义, 在 JavaScript 1.7 实现 var jsonObj = JSON.parse(val); return _isPlainObject(jsonObj); @@ -1546,8 +1562,8 @@ module.exports = _isJSON; /***/ (function(module, exports, __webpack_require__) { -var _isMobile = __webpack_require__(14); -var _isTelephone = __webpack_require__(16); +var _isMobile = __webpack_require__(17); +var _isTelephone = __webpack_require__(19); /** * 校验参数 `val` 是否为手机号码/座机号码 diff --git a/validator.min.js b/validator.min.js index 49359f9..6d66134 100644 --- a/validator.min.js +++ b/validator.min.js @@ -1 +1 @@ -!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.jxmValidator=n():t.jxmValidator=n()}("undefined"!=typeof self?self:this,function(){return function(t){var n={};function r(e){if(n[e])return n[e].exports;var i=n[e]={i:e,l:!1,exports:{}};return t[e].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=n,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:e})},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=17)}([function(t,n,r){var e=r(4),i=r(5);t.exports=function(t){return i(e.OBJECT,t)}},function(t,n){t.exports={INTEGER_REX:/^-?\d+$/,POSITIVE_INTEGER_REX:/^[1-9]\d*$/,NEGATIVE_INTEGER_REX:/^-[1-9]\d*$/,UN_POSITIVE_INTEGER_REX:/^-[1-9]\d*$|^0$/,UN_NEGATIVE_INTEGER_REX:/^[1-9]\d*$|^0$/,POSITIVE_NUMBER_REX:/^[1-9]\d*(\.\d)*$|^0\.\d*[1-9]\d*$/,NEGATIVE_NUMBER_REX:/^-[1-9]\d*(\.\d)*$|^-0\.\d*[1-9]\d*$/,UN_NEGATIVE_NUMBER_REX:/^[1-9]\d*(\.\d)*$|^0\.\d*[1-9]\d*$|^0$/,UN_POSITIVE_NUMBER_REX:/^-[1-9]\d*(\.\d)*$|^-0\.\d*[1-9]\d*$|^0$/,EMAIL_REX:/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/,TELEPHONE_REX:{"zh-CN":/^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/},MOBILE_REX:{"zh-CN":/^(\+?0?86-?)?1\d{10}$/},IPV4_REX:/\b((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])\.((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])\.((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])\.((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])\b/}},function(t,n,r){var e=r(4),i=r(5);t.exports=function(t){return typeof t===e.NUMBER||i(e.NUMBER,t)}},function(t,n,r){var e=r(4),i=r(5);t.exports=function(t){return typeof t===e.STRING||i(e.STRING,t)}},function(t,n){var r={};["NULL","UNDEFINED","BOOLEAN","NUMBER","STRING","SYMBOL","OBJECT","ARRAY","SET","MAP","WEAKSET","WEAKMAP","FUNCTION","DATE"].forEach(t=>{r[t]=t.toLowerCase()}),t.exports=r},function(t,n){var r,e=null,i="[object Null]",o="[object Undefined]",u=/^\[object\u0020|\]$/gi,E=Object.prototype.toString;t.exports=function(t,n){return(n===r?o:n===e?i:E.call(n)).replace(u,"").toLowerCase()===t}},function(t,n,r){var e=r(7),i=r(2),o=r(0),u=r(9);t.exports=function(t,n){var r=o(n)?n:{};return i(t)?!e(t):!(!0===r.isStrict||!u(t,{isStrict:!0})||e(t-0))}},function(t,n){t.exports=function(t){return t!=t}},function(t,n){var r=1/0,e=-1/0;t.exports=function(t){return t===r||t===e}},function(t,n,r){var e=r(3),i=r(0);t.exports=function(t,n){var r=i(n)?n:{};return!!e(t)&&(!1===r.isStrict?""!==t:""!==t.trim())}},function(t,n,r){var e=r(6),i=r(8);t.exports=function(t,n){return e(t,n)&&!i(t)}},function(t,n,r){var e=r(4),i=r(5);t.exports=function(t){return i(e.ARRAY,t)}},function(t,n,r){var e=r(0),i=r(13);t.exports=function(t){if(!e(t))return!1;var n=Object.getPrototypeOf(t);if(null===n)return!0;var r=n.constructor;return i(r)}},function(t,n,r){var e=r(4),i=r(5);t.exports=function(t){return i(e.FUNCTION,t)}},function(t,n,r){var e=r(3),i=r(15),o=r(1);t.exports=function(t,n){var r=e(n)?n:i.ZHCN,u=o.MOBILE_REX[r];return!!u&&!!e(t)&&u.test(t)}},function(t,n){t.exports={ZHCN:"zh-CN"}},function(t,n,r){var e=r(3),i=r(15),o=r(1);t.exports=function(t,n){var r=e(n)?n:i.ZHCN,u=o.TELEPHONE_REX[r];return!!u&&!!e(t)&&u.test(t)}},function(t,n,r){var e=r(18),i=r(19),o=r(20),u=r(21),E=r(7),s=r(8),c=r(2),f=r(6),N=r(10),a=r(22),_=r(23),R=r(24),d=r(25),p=r(26),I=r(27),v=r(28),T=r(29),x=r(30),l=r(31),U=r(32),S=r(3),O=r(33),X=r(9),G=r(11),A=r(34),V=r(0),P=r(12),B=r(35),M=r(13),b=r(14),$=r(16),m=r(36),y=r(37),g=r(38);t.exports={isUndefined:e,isNull:i,isNil:o,isBoolean:u,isNaN:E,isInfinity:s,isNumber:c,isRealNumber:f,isNumeric:N,isZero:a,isUnZero:_,isPositiveNumber:R,isNegativeNumber:d,isUnPositiveNumber:p,isUnNegativeNumber:I,isInteger:v,isPositiveInteger:T,isNegativeInteger:x,isUnPositiveInteger:l,isUnNegativeInteger:U,isString:S,isEmptyString:O,isUnEmptyString:X,isArray:G,isEmptyArray:A,isObject:V,isPlainObject:P,isJSON:B,isFunction:M,isMobile:b,isTelephone:$,isPhone:m,isEmail:y,isIpv4:g}},function(t,n){t.exports=function(t){return void 0===t}},function(t,n){t.exports=function(t){return null===t}},function(t,n){t.exports=function(t){return void 0===t||null===t}},function(t,n,r){var e=r(4),i=r(5);t.exports=function(t){return typeof t===e.BOOLEAN||i(e.BOOLEAN,t)}},function(t,n,r){var e=r(0),i=r(6);t.exports=function(t,n){return!0===(e(n)?n:{}).isStrict?0===t:i(t)&&t-0==0}},function(t,n,r){var e=r(10);t.exports=function(t,n){return e(t,n)&&t-0!=0}},function(t,n,r){var e=r(2),i=r(0),o=r(1);t.exports=function(t,n){return!0===(i(n)?n:{}).isStrict?e(t)&&o.POSITIVE_NUMBER_REX.test(t):o.POSITIVE_NUMBER_REX.test(t)}},function(t,n,r){var e=r(2),i=r(0),o=r(1);t.exports=function(t,n){return!0===(i(n)?n:{}).isStrict?e(t)&&o.NEGATIVE_NUMBER_REX.test(t):o.NEGATIVE_NUMBER_REX.test(t)}},function(t,n,r){var e=r(2),i=r(0),o=r(1);t.exports=function(t,n){return!0===(i(n)?n:{}).isStrict?e(t)&&o.UN_POSITIVE_NUMBER_REX.test(t):o.UN_POSITIVE_NUMBER_REX.test(t)}},function(t,n,r){var e=r(2),i=r(0),o=r(1);t.exports=function(t,n){return!0===(i(n)?n:{}).isStrict?e(t)&&o.UN_NEGATIVE_NUMBER_REX.test(t):o.UN_NEGATIVE_NUMBER_REX.test(t)}},function(t,n,r){var e=r(2),i=r(0),o=r(1);t.exports=function(t,n){return!0===(i(n)?n:{}).isStrict?e(t)&&o.INTEGER_REX.test(t):o.INTEGER_REX.test(t)}},function(t,n,r){var e=r(2),i=r(0),o=r(1);t.exports=function(t,n){return!0===(i(n)?n:{}).isStrict?e(t)&&o.POSITIVE_INTEGER_REX.test(t):o.POSITIVE_INTEGER_REX.test(t)}},function(t,n,r){var e=r(2),i=r(0),o=r(1);t.exports=function(t,n){return!0===(i(n)?n:{}).isStrict?e(t)&&o.NEGATIVE_INTEGER_REX.test(t):o.NEGATIVE_INTEGER_REX.test(t)}},function(t,n,r){var e=r(2),i=r(0),o=r(1);t.exports=function(t,n){return!0===(i(n)?n:{}).isStrict?e(t)&&o.UN_POSITIVE_INTEGER_REX.test(t):o.UN_POSITIVE_INTEGER_REX.test(t)}},function(t,n,r){var e=r(2),i=r(0),o=r(1);t.exports=function(t,n){return!0===(i(n)?n:{}).isStrict?e(t)&&o.UN_NEGATIVE_INTEGER_REX.test(t):o.UN_NEGATIVE_INTEGER_REX.test(t)}},function(t,n,r){var e=r(3),i=r(0);t.exports=function(t,n){var r=i(n)?n:{};return!!e(t)&&(!1===r.isStrict?""===t:""===t.trim())}},function(t,n,r){var e=r(11);t.exports=function(t){return!!e(t)&&0===t.length}},function(t,n,r){var e=r(3),i=r(12);t.exports=function(t){if(!e(t))return!1;try{var n=JSON.parse(t);return i(n)}catch(t){return!1}}},function(t,n,r){var e=r(14),i=r(16);t.exports=function(t,n){return e(t,n)||i(t,n)}},function(t,n,r){var e=r(3),i=r(1);t.exports=function(t){return!!e(t)&&i.EMAIL_REX.test(t)}},function(t,n,r){var e=r(3),i=r(1);t.exports=function(t){return!!e(t)&&i.IPV4_REX.test(t)}}])}); \ No newline at end of file +!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.jxmValidator=n():t.jxmValidator=n()}("undefined"!=typeof self?self:this,function(){return function(t){var n={};function r(e){if(n[e])return n[e].exports;var i=n[e]={i:e,l:!1,exports:{}};return t[e].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=n,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:e})},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=20)}([function(t,n,r){var e=r(4),i=r(5);t.exports=function(t){return i(e.OBJECT,t)}},function(t,n){t.exports={POSITIVE_NUMBER_REX:/^[1-9]\d*(\.\d*)?$|^0?\.\d*[1-9]\d*$/,NEGATIVE_NUMBER_REX:/^-[1-9]\d*(\.\d*)?$|^-0?\.\d*[1-9]\d*$/,INTEGER_REX:/^-?\d+$/,POSITIVE_INTEGER_REX:/^[1-9]\d*$/,NEGATIVE_INTEGER_REX:/^-[1-9]\d*$/,UN_POSITIVE_INTEGER_REX:/^-[1-9]\d*$|^0$/,UN_NEGATIVE_INTEGER_REX:/^[1-9]\d*$|^0$/,LEFT_WHITE_SPACE_REX:/^\s\s*/,RIGHT_WHITE_SPACE_REX:/\s\s*$/,TELEPHONE_REX:{"zh-CN":/^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/},MOBILE_REX:{"zh-CN":/^(\+?0?86-?)?1\d{10}$/},EMAIL_REX:/^[a-zA-Z0-9]+([._\\-]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/,IPV4_REX:/\b((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])\.((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])\.((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])\.((?!\d\d\d)\d+|1\d\d|2[0-4]\d|25[0-5])\b/}},function(t,n,r){var e=r(4),i=r(5);t.exports=function(t){return typeof t===e.NUMBER||i(e.NUMBER,t)}},function(t,n,r){var e=r(4),i=r(5);t.exports=function(t){return typeof t===e.STRING||i(e.STRING,t)}},function(t,n){var r={};["NULL","UNDEFINED","BOOLEAN","NUMBER","STRING","SYMBOL","OBJECT","ARRAY","SET","MAP","WEAKSET","WEAKMAP","FUNCTION","DATE"].forEach(t=>{r[t]=t.toLowerCase()}),t.exports=r},function(t,n){var r,e=null,i="[object Null]",o="[object Undefined]",u=/^\[object\u0020|\]$/gi,s=Object.prototype.toString;t.exports=function(t,n){return(n===r?o:n===e?i:s.call(n)).replace(u,"").toLowerCase()===t}},function(t,n,r){var e=r(8),i=r(2),o=r(0),u=r(10);t.exports=function(t,n){var r=o(n)?n:{};return i(t)?!e(t):!(!0===r.isStrict||!u(t,{isStrict:!0})||e(t-0))}},function(t,n,r){var e=r(0),i=r(2),o=r(6);t.exports=function(t,n){var r=e(n)?n:{};return i(t)?t-0==0:!0!==r.isStrict&&o(t)&&t-0==0}},function(t,n){t.exports=function(t){return t!=t}},function(t,n){var r=1/0,e=-1/0;t.exports=function(t){return t===r||t===e}},function(t,n,r){var e=r(3),i=r(0);t.exports=function(t,n){var r=i(n)?n:{};return!!e(t)&&(!1===r.isStrict?""!==t:""!==t.trim())}},function(t,n,r){var e=r(6),i=r(9);t.exports=function(t,n){return e(t,n)&&!i(t)}},function(t,n,r){var e=r(2),i=r(0),o=r(1);t.exports=function(t,n){return!0===(i(n)?n:{}).isStrict?e(t)&&o.POSITIVE_NUMBER_REX.test(t):o.POSITIVE_NUMBER_REX.test(t)}},function(t,n,r){var e=r(2),i=r(0),o=r(1);t.exports=function(t,n){return!0===(i(n)?n:{}).isStrict?e(t)&&o.NEGATIVE_NUMBER_REX.test(t):o.NEGATIVE_NUMBER_REX.test(t)}},function(t,n,r){var e=r(4),i=r(5);t.exports=function(t){return i(e.ARRAY,t)}},function(t,n,r){var e=r(0),i=r(16);t.exports=function(t){if(!e(t))return!1;var n=Object.getPrototypeOf(t);if(null===n)return!0;var r=n.constructor;return i(r)}},function(t,n,r){var e=r(4),i=r(5);t.exports=function(t){return i(e.FUNCTION,t)}},function(t,n,r){var e=r(3),i=r(18),o=r(1);t.exports=function(t,n){var r=e(n)?n:i.ZHCN,u=o.MOBILE_REX[r];return!!u&&!!e(t)&&u.test(t)}},function(t,n){t.exports={ZHCN:"zh-CN"}},function(t,n,r){var e=r(3),i=r(18),o=r(1);t.exports=function(t,n){var r=e(n)?n:i.ZHCN,u=o.TELEPHONE_REX[r];return!!u&&!!e(t)&&u.test(t)}},function(t,n,r){var e=r(21),i=r(22),o=r(23),u=r(24),s=r(8),E=r(9),c=r(2),f=r(6),a=r(11),N=r(7),p=r(25),I=r(12),R=r(13),d=r(26),_=r(27),v=r(28),x=r(29),T=r(30),l=r(31),S=r(32),O=r(3),X=r(33),A=r(10),G=r(14),U=r(34),P=r(0),b=r(15),V=r(35),m=r(16),y=r(17),g=r(19),B=r(36),M=r(37),$=r(38);t.exports={isUndefined:e,isNull:i,isNil:o,isBoolean:u,isNaN:s,isInfinity:E,isNumber:c,isRealNumber:f,isNumeric:a,isZero:N,isUnZero:p,isPositiveNumber:I,isNegativeNumber:R,isUnPositiveNumber:d,isUnNegativeNumber:_,isInteger:v,isPositiveInteger:x,isNegativeInteger:T,isUnPositiveInteger:l,isUnNegativeInteger:S,isString:O,isEmptyString:X,isUnEmptyString:A,isArray:G,isEmptyArray:U,isObject:P,isPlainObject:b,isJSON:V,isFunction:m,isMobile:y,isTelephone:g,isPhone:B,isEmail:M,isIpv4:$}},function(t,n){t.exports=function(t){return void 0===t}},function(t,n){t.exports=function(t){return null===t}},function(t,n){t.exports=function(t){return void 0===t||null===t}},function(t,n,r){var e=r(4),i=r(5);t.exports=function(t){return typeof t===e.BOOLEAN||i(e.BOOLEAN,t)}},function(t,n,r){var e=r(11);t.exports=function(t,n){return e(t,n)&&t-0!=0}},function(t,n,r){var e=r(7),i=r(13);t.exports=function(t,n){return i(t,n)||e(t,n)}},function(t,n,r){var e=r(7),i=r(12);t.exports=function(t,n){return i(t,n)||e(t,n)}},function(t,n,r){var e=r(2),i=r(0),o=r(1);t.exports=function(t,n){return!0===(i(n)?n:{}).isStrict?e(t)&&o.INTEGER_REX.test(t):o.INTEGER_REX.test(t)}},function(t,n,r){var e=r(2),i=r(0),o=r(1);t.exports=function(t,n){return!0===(i(n)?n:{}).isStrict?e(t)&&o.POSITIVE_INTEGER_REX.test(t):o.POSITIVE_INTEGER_REX.test(t)}},function(t,n,r){var e=r(2),i=r(0),o=r(1);t.exports=function(t,n){return!0===(i(n)?n:{}).isStrict?e(t)&&o.NEGATIVE_INTEGER_REX.test(t):o.NEGATIVE_INTEGER_REX.test(t)}},function(t,n,r){var e=r(2),i=r(0),o=r(1);t.exports=function(t,n){return!0===(i(n)?n:{}).isStrict?e(t)&&o.UN_POSITIVE_INTEGER_REX.test(t):o.UN_POSITIVE_INTEGER_REX.test(t)}},function(t,n,r){var e=r(2),i=r(0),o=r(1);t.exports=function(t,n){return!0===(i(n)?n:{}).isStrict?e(t)&&o.UN_NEGATIVE_INTEGER_REX.test(t):o.UN_NEGATIVE_INTEGER_REX.test(t)}},function(t,n,r){var e=r(3),i=r(0);t.exports=function(t,n){var r=i(n)?n:{};return!!e(t)&&(!1===r.isStrict?""===t:""===t.trim())}},function(t,n,r){var e=r(14);t.exports=function(t){return!!e(t)&&0===t.length}},function(t,n,r){var e=r(3),i=r(15);t.exports=function(t){if(!e(t))return!1;try{var n=JSON.parse(t);return i(n)}catch(t){return!1}}},function(t,n,r){var e=r(17),i=r(19);t.exports=function(t,n){return e(t,n)||i(t,n)}},function(t,n,r){var e=r(3),i=r(1);t.exports=function(t){return!!e(t)&&i.EMAIL_REX.test(t)}},function(t,n,r){var e=r(3),i=r(1);t.exports=function(t){return!!e(t)&&i.IPV4_REX.test(t)}}])}); \ No newline at end of file