diff --git a/README.md b/README.md index 4446ab3..5750108 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,13 @@ validator =========================== -[![Build Status](https://travis-ci.org/sTdobTs/validator.svg?branch=master)](https://travis-ci.org/sTdobTs/validator) [![NPM version](http://img.shields.io/npm/v/jxm-validator.svg)](https://npmjs.org/package/jxm-validator) +[![Build Status](https://travis-ci.org/sTdobTs/validator.svg?branch=master)](https://travis-ci.org/sTdobTs/validator) [![Coverage Status](https://coveralls.io/repos/github/sTdobTs/validator/badge.svg?branch=master)](https://coveralls.io/github/sTdobTs/validator?branch=master) [![Downloads](http://img.shields.io/npm/dm/jxm-validator.svg)](https://npmjs.org/package/jxm-validator) +[![License](https://img.shields.io/npm/l/jxm-validator.svg?maxAge=2592000)](https://github.com/sTdobTs/validator/blob/master/LICENSE) + +> [中文](https://github.com/sTdobTs/validator/blob/master/README.zh-CN.md) | [English](https://github.com/sTdobTs/validator) This is a modern JavaScript verification toolkit library, running on Node.js and in the modern browser, provide feature-rich verification function, making verification simple and fun. @@ -44,7 +47,7 @@ In Node.js: ## Documentation -API Docs, please see [here](https://github.com/sTdobTs/validator/blob/master/docs/en-US/APIs.md). +API Docs, please open [here](https://github.com/sTdobTs/validator/blob/master/docs/en-US/APIs.md). ## Community @@ -52,7 +55,7 @@ If you have any question, please open an issue [here](https://github.com/sTdobTs ## Changelog -If you search all changes, please open [here](https://github.com/sTdobTs/validator/wiki/Changelog) +If you see all changes, please open [here](https://github.com/sTdobTs/validator/wiki/Changelog) ## License diff --git a/README.zh-CN.md b/README.zh-CN.md index f8106f5..8d108f8 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -2,10 +2,13 @@ validator =========================== -[![Build Status](https://travis-ci.org/sTdobTs/validator.svg?branch=master)](https://travis-ci.org/sTdobTs/validator) [![NPM version](http://img.shields.io/npm/v/jxm-validator.svg)](https://npmjs.org/package/jxm-validator) +[![Build Status](https://travis-ci.org/sTdobTs/validator.svg?branch=master)](https://travis-ci.org/sTdobTs/validator) [![Coverage Status](https://coveralls.io/repos/github/sTdobTs/validator/badge.svg?branch=master)](https://coveralls.io/github/sTdobTs/validator?branch=master) [![Downloads](http://img.shields.io/npm/dm/jxm-validator.svg)](https://npmjs.org/package/jxm-validator) +[![License](https://img.shields.io/npm/l/jxm-validator.svg?maxAge=2592000)](https://github.com/sTdobTs/validator/blob/master/LICENSE) + +> [中文](https://github.com/sTdobTs/validator/blob/master/README.zh-CN.md) | [English](https://github.com/sTdobTs/validator) 基于 ECMAScript5.1 实现的验证工具包,提供了丰富的校验和工具方法,在 Node.js 和现代浏览器中可以使用。 @@ -28,15 +31,15 @@ validator 在 Node.js 中使用: ```javascript - // reference + // 引用 const jxmValidator = require('jxm-validator'); - // Check negative number + // 检验 负数 jxmValidator.isNegativeNumber(-2); // => true jxmValidator.isNegativeNumber(-2.3); // => true jxmValidator.isNegativeNumber(2.3); // => false - // Check postive integer + // 校验 正整数 jxmValidator.isPositiveInteger(2); // => true jxmValidator.isPositiveInteger(2.3); // => false jxmValidator.isPositiveInteger(-2); // => false diff --git a/docs/en-US/APIs.md b/docs/en-US/APIs.md index 0e105f1..c1f89cb 100644 --- a/docs/en-US/APIs.md +++ b/docs/en-US/APIs.md @@ -2,9 +2,10 @@ API 文档 =========================== -假设,您已经阅读,并且已经知道如何使用,可以直接跳过该步骤。如果还没有看过的同学,请看这里,引入`jxm-validator`: +假设,您已经阅读,并且知道如何使用,可以直接跳过该步骤。若是还没有看过的同学,请看这里: ```javascript + // 引入 `jxm-validator` const jxmValidator = require('jxm-validator'); jxmValidator.isNull(null); diff --git a/docs/en-US/APIs/isArray.md b/docs/en-US/APIs/isArray.md index 8844448..28b2cc5 100644 --- a/docs/en-US/APIs/isArray.md +++ b/docs/en-US/APIs/isArray.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val 为 `array` 时,返回 `true`, 否则返回 `false` + 当参数 val 为 `array` 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/en-US/APIs/isBoolean.md b/docs/en-US/APIs/isBoolean.md index 7dfcf93..88f36fd 100644 --- a/docs/en-US/APIs/isBoolean.md +++ b/docs/en-US/APIs/isBoolean.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val 为 `boolean` 时,返回 `true`, 否则返回 `false` + 当参数 val 为 `boolean` 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/en-US/APIs/isEmail.md b/docs/en-US/APIs/isEmail.md index 268c077..1fc1837 100644 --- a/docs/en-US/APIs/isEmail.md +++ b/docs/en-US/APIs/isEmail.md @@ -22,4 +22,5 @@ jxmValidator.isEmail('575099329@qq'); // => false jxmValidator.isEmail('dotx575099329@gmail.com'); // => true jxmValidator.isEmail('dotx575099329@163.com'); // => true jxmValidator.isEmail('dotx575099329@qingniu.co'); // => true +jxmValidator.isEmail(333); // => false ``` diff --git a/docs/en-US/APIs/isEmptyString.md b/docs/en-US/APIs/isEmptyString.md index 626e63f..68731e0 100644 --- a/docs/en-US/APIs/isEmptyString.md +++ b/docs/en-US/APIs/isEmptyString.md @@ -15,7 +15,9 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式,默认采用严格模式 + 该接口存在两种模式, 即严格模式、非严格模式 + + 默认采用 `严格模式` 若参数 `val` 不是 string, 则直接返回 false 若参数 `val` 是 string 并且为空(''), 则返回 true, 否则返回 false @@ -32,11 +34,19 @@ #### 示例: ```javascript +jxmValidator.isEmptyString(3); // => false jxmValidator.isEmptyString('3'); // => false +jxmValidator.isEmptyString(0); // => false + jxmValidator.isEmptyString(''); // => true jxmValidator.isEmptyString('', {isStrict: false})); // => true jxmValidator.isEmptyString(' '); // => 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/isFunction.md b/docs/en-US/APIs/isFunction.md index 6617dbe..8aceca3 100644 --- a/docs/en-US/APIs/isFunction.md +++ b/docs/en-US/APIs/isFunction.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val 为 `function` 时,返回 `true`, 否则返回 `false` + 当参数 val 为 `function` 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/en-US/APIs/isInfinity.md b/docs/en-US/APIs/isInfinity.md index e58de7c..33412c2 100644 --- a/docs/en-US/APIs/isInfinity.md +++ b/docs/en-US/APIs/isInfinity.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val 为 `Infinity` 或 `-Infinity` 时,返回 `true`, 否则返回 `false` + 当且仅当参数 val 为 `Infinity` 或 `-Infinity` 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/en-US/APIs/isInteger.md b/docs/en-US/APIs/isInteger.md index 4c5a007..60d05eb 100644 --- a/docs/en-US/APIs/isInteger.md +++ b/docs/en-US/APIs/isInteger.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是整数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为整数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,19 +38,35 @@ ```javascript jxmValidator.isInteger(3); // => true jxmValidator.isInteger('3'); // => true -jxmValidator.isInteger(3.3); // => false -jxmValidator.isInteger('3.3'); // => false +jxmValidator.isInteger(3, {isStrict: true}); // => true +jxmValidator.isInteger('3', {isStrict: true}); // => false + +jxmValidator.isInteger(0); // => true +jxmValidator.isInteger('0'); // => true +jxmValidator.isInteger(0, {isStrict: true}); // => true +jxmValidator.isInteger('0', {isStrict: true}); // => false jxmValidator.isInteger(-3); // => true jxmValidator.isInteger('-3'); // => true -jxmValidator.isInteger(-3.3); // => false -jxmValidator.isInteger('-3.3'); // => false +jxmValidator.isInteger(-3, {isStrict: true}); // => true +jxmValidator.isInteger('-3', {isStrict: true}); // => false -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', {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(0); // => true -jxmValidator.isInteger('0'); // => true +jxmValidator.isInteger(''); // => false +jxmValidator.isInteger(' '); // => false +jxmValidator.isInteger(null); // => false +jxmValidator.isInteger(undefined); // => false + +jxmValidator.isInteger(NaN); // => false +jxmValidator.isInteger(Number.POSITIVE_INFINITY); // => false +jxmValidator.isInteger(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/en-US/APIs/isJSON.md b/docs/en-US/APIs/isJSON.md index 470c79d..e010a72 100644 --- a/docs/en-US/APIs/isJSON.md +++ b/docs/en-US/APIs/isJSON.md @@ -17,6 +17,7 @@ ```javascript jxmValidator.isJSON('{"a": 3}'); // => true +jxmValidator.isJSON('{a: 3}'); // => false jxmValidator.isJSON('[3, 4]'); // => false jxmValidator.isJSON('3'); // => false diff --git a/docs/en-US/APIs/isMobile.md b/docs/en-US/APIs/isMobile.md index c2c804b..5635b1e 100644 --- a/docs/en-US/APIs/isMobile.md +++ b/docs/en-US/APIs/isMobile.md @@ -9,7 +9,7 @@ val,任意类型 - locale,可选参数,默认值 'ZHCN' + locale,可选参数,默认值 'zh-CN' #### 说明: @@ -26,8 +26,14 @@ ```javascript jxmValidator.isMobile('18505505933'); // => true jxmValidator.isMobile('28505505933'); // => false + jxmValidator.isMobile('185055059334'); // => false jxmValidator.isMobile('1850550593'); // => false + jxmValidator.isMobile('1850550 933'); // => false jxmValidator.isMobile('1850550-933'); // => false + +jxmValidator.isMobile(18505505933); // => false + +jxmValidator.isMobile('18505505933', 'en-US'); // => false ``` diff --git a/docs/en-US/APIs/isNaN.md b/docs/en-US/APIs/isNaN.md index b2d8770..dcc2c87 100644 --- a/docs/en-US/APIs/isNaN.md +++ b/docs/en-US/APIs/isNaN.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val 为 `NaN` 时,返回 `true`, 否则返回 `false` + 当且仅当参数 val 为 `NaN` 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/en-US/APIs/isNegativeInteger.md b/docs/en-US/APIs/isNegativeInteger.md index 481a64e..95ee1d8 100644 --- a/docs/en-US/APIs/isNegativeInteger.md +++ b/docs/en-US/APIs/isNegativeInteger.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是负整数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为负整数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,19 +38,35 @@ ```javascript jxmValidator.isNegativeInteger(3); // => false jxmValidator.isNegativeInteger('3'); // => false -jxmValidator.isNegativeInteger(3.3); // => false -jxmValidator.isNegativeInteger('3.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); // => true jxmValidator.isNegativeInteger('-3'); // => true -jxmValidator.isNegativeInteger(-3.3); // => false -jxmValidator.isNegativeInteger('-3.3'); // => false +jxmValidator.isNegativeInteger(-3, {isStrict: true}); // => true +jxmValidator.isNegativeInteger('-3', {isStrict: true}); // => false -jxmValidator.isNegativeInteger('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('-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(''); // => false +jxmValidator.isNegativeInteger(' '); // => false +jxmValidator.isNegativeInteger(null); // => false +jxmValidator.isNegativeInteger(undefined); // => false + +jxmValidator.isNegativeInteger(NaN); // => false +jxmValidator.isNegativeInteger(Number.POSITIVE_INFINITY); // => false +jxmValidator.isNegativeInteger(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/en-US/APIs/isNegativeNumber.md b/docs/en-US/APIs/isNegativeNumber.md index 730c997..867576d 100644 --- a/docs/en-US/APIs/isNegativeNumber.md +++ b/docs/en-US/APIs/isNegativeNumber.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是负数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为负数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,11 +38,25 @@ ```javascript jxmValidator.isNegativeNumber(-3); // => true jxmValidator.isNegativeNumber('-3'); // => true +jxmValidator.isNegativeNumber(-3, {isStrict: true}); // => true jxmValidator.isNegativeNumber('-3', {isStrict: true}); // => false jxmValidator.isNegativeNumber(0); // => false jxmValidator.isNegativeNumber('0'); // => false +jxmValidator.isNegativeNumber(0, {isStrict: true}); // => false +jxmValidator.isNegativeNumber('0', {isStrict: true}); // => false jxmValidator.isNegativeNumber(3); // => false jxmValidator.isNegativeNumber('3'); // => false +jxmValidator.isNegativeNumber(3, {isStrict: true}); // => false +jxmValidator.isNegativeNumber('3', {isStrict: true}); // => false + +jxmValidator.isNegativeNumber(''); // => false +jxmValidator.isNegativeNumber(' '); // => false +jxmValidator.isNegativeNumber(null); // => false +jxmValidator.isNegativeNumber(undefined); // => false + +jxmValidator.isNegativeNumber(NaN); // => false +jxmValidator.isNegativeNumber(Number.POSITIVE_INFINITY); // => false +jxmValidator.isNegativeNumber(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/en-US/APIs/isNil.md b/docs/en-US/APIs/isNil.md index 8e2377a..34dc0d4 100644 --- a/docs/en-US/APIs/isNil.md +++ b/docs/en-US/APIs/isNil.md @@ -11,7 +11,7 @@ #### 说明: - 当参数 val === null 或者 val === undefined 时,返回 `true`, 否则返回 `false` + 当且仅当参数 val === null 或者 val === undefined 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/en-US/APIs/isNull.md b/docs/en-US/APIs/isNull.md index cb93469..716af9e 100644 --- a/docs/en-US/APIs/isNull.md +++ b/docs/en-US/APIs/isNull.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val === null 时,返回 `true`, 否则返回 `false` + 当且仅当参数 val === null 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/en-US/APIs/isNumber.md b/docs/en-US/APIs/isNumber.md index 414a6a8..27da65c 100644 --- a/docs/en-US/APIs/isNumber.md +++ b/docs/en-US/APIs/isNumber.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val 为 `number` 时,返回 `true`, 否则返回 `false` + 当参数 val 为 `number` 时,返回 `true`, 否则返回 `false` * number 类型还包括: NaN, Infinity, -Infinity diff --git a/docs/en-US/APIs/isNumeric.md b/docs/en-US/APIs/isNumeric.md index 64251a8..d252f81 100644 --- a/docs/en-US/APIs/isNumeric.md +++ b/docs/en-US/APIs/isNumeric.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且不是 NaN, Infinity, -Infinity, 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且可以经过 ToNumber 转换为非 NaN, Infinity, -Infinity 的数字, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,6 +38,7 @@ ```javascript jxmValidator.isNumeric(3); // => true jxmValidator.isNumeric('3'); // => true +jxmValidator.isNumeric(3, {isStrict: true}); // => true jxmValidator.isNumeric('3', {isStrict: true}); // => false jxmValidator.isNumeric('3a'); // => false @@ -42,6 +47,7 @@ jxmValidator.isNumeric(Number.POSITIVE_INFINITY); // => false jxmValidator.isNumeric(Number.NEGATIVE_INFINITY); // => false jxmValidator.isNumeric(''); // => false +jxmValidator.isNumeric(' '); // => false jxmValidator.isNumeric(null); // => false jxmValidator.isNumeric(undefined); // => false diff --git a/docs/en-US/APIs/isObject.md b/docs/en-US/APIs/isObject.md index a4b1aee..ffa0379 100644 --- a/docs/en-US/APIs/isObject.md +++ b/docs/en-US/APIs/isObject.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val 为 `object` 时,返回 `true`, 否则返回 `false` + 当参数 val 为 `object` 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/en-US/APIs/isPhone.md b/docs/en-US/APIs/isPhone.md index d091425..bbc72c5 100644 --- a/docs/en-US/APIs/isPhone.md +++ b/docs/en-US/APIs/isPhone.md @@ -9,7 +9,7 @@ val,任意类型 - locale,可选参数,默认值 'ZHCN' + locale,可选参数,默认值 'zh-CN' #### 说明: diff --git a/docs/en-US/APIs/isPositiveInteger.md b/docs/en-US/APIs/isPositiveInteger.md index 3216ab8..9df6985 100644 --- a/docs/en-US/APIs/isPositiveInteger.md +++ b/docs/en-US/APIs/isPositiveInteger.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是正整数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为正整数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,19 +38,35 @@ ```javascript jxmValidator.isPositiveInteger(3); // => true jxmValidator.isPositiveInteger('3'); // => true -jxmValidator.isPositiveInteger(3.3); // => false -jxmValidator.isPositiveInteger('3.3'); // => false +jxmValidator.isPositiveInteger(3, {isStrict: true}); // => true +jxmValidator.isPositiveInteger('3', {isStrict: true}); // => false + +jxmValidator.isPositiveInteger(0); // => false +jxmValidator.isPositiveInteger('0'); // => false +jxmValidator.isPositiveInteger(0, {isStrict: true}); // => false +jxmValidator.isPositiveInteger('0', {isStrict: true}); // => false jxmValidator.isPositiveInteger(-3); // => false jxmValidator.isPositiveInteger('-3'); // => false -jxmValidator.isPositiveInteger(-3.3); // => false -jxmValidator.isPositiveInteger('-3.3'); // => false +jxmValidator.isPositiveInteger(-3, {isStrict: true}); // => 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', {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(0); // => false -jxmValidator.isPositiveInteger('0'); // => false +jxmValidator.isPositiveInteger(''); // => false +jxmValidator.isPositiveInteger(' '); // => false +jxmValidator.isPositiveInteger(null); // => false +jxmValidator.isPositiveInteger(undefined); // => false + +jxmValidator.isPositiveInteger(NaN); // => false +jxmValidator.isPositiveInteger(Number.POSITIVE_INFINITY); // => false +jxmValidator.isPositiveInteger(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/en-US/APIs/isPositiveNumber.md b/docs/en-US/APIs/isPositiveNumber.md index 81e5eff..a29a723 100644 --- a/docs/en-US/APIs/isPositiveNumber.md +++ b/docs/en-US/APIs/isPositiveNumber.md @@ -3,7 +3,7 @@ #### 描述: - 校验参数 `val` 是否为正整数 + 校验参数 `val` 是否为正数 #### 参数: @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是正数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为正数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,11 +38,25 @@ ```javascript jxmValidator.isPositiveNumber(3); // => true jxmValidator.isPositiveNumber('3'); // => true +jxmValidator.isPositiveNumber(3, {isStrict: true}); // => true jxmValidator.isPositiveNumber('3', {isStrict: true}); // => false jxmValidator.isPositiveNumber(0); // => false jxmValidator.isPositiveNumber('0'); // => false +jxmValidator.isPositiveNumber(0, {isStrict: true}); // => false +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(''); // => false +jxmValidator.isPositiveNumber(' '); // => false +jxmValidator.isPositiveNumber(null); // => false +jxmValidator.isPositiveNumber(undefined); // => false + +jxmValidator.isPositiveNumber(NaN); // => false +jxmValidator.isPositiveNumber(Number.POSITIVE_INFINITY); // => false +jxmValidator.isPositiveNumber(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/en-US/APIs/isRealNumber.md b/docs/en-US/APIs/isRealNumber.md index ee0808b..beb5fd7 100644 --- a/docs/en-US/APIs/isRealNumber.md +++ b/docs/en-US/APIs/isRealNumber.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且不是 NaN, 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且可以经过 ToNumber 转换为非 NaN 的数字, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,6 +38,7 @@ ```javascript jxmValidator.isRealNumber(3); // => true jxmValidator.isRealNumber('3'); // => true +jxmValidator.isRealNumber(3, {isStrict: true}); // => true jxmValidator.isRealNumber('3', {isStrict: true}); // => false jxmValidator.isRealNumber('3a'); // => false @@ -42,6 +47,7 @@ jxmValidator.isRealNumber(Number.POSITIVE_INFINITY); // => true jxmValidator.isRealNumber(Number.NEGATIVE_INFINITY); // => true jxmValidator.isRealNumber(''); // => false +jxmValidator.isRealNumber(' '); // => false jxmValidator.isRealNumber(null); // => false jxmValidator.isRealNumber(undefined); // => false diff --git a/docs/en-US/APIs/isString.md b/docs/en-US/APIs/isString.md index e9d0f60..f3a8674 100644 --- a/docs/en-US/APIs/isString.md +++ b/docs/en-US/APIs/isString.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val 为 `string` 时,返回 `true`, 否则返回 `false` + 当参数 val 为 `string` 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/en-US/APIs/isTelephone.md b/docs/en-US/APIs/isTelephone.md index cd1a1d0..ecccace 100644 --- a/docs/en-US/APIs/isTelephone.md +++ b/docs/en-US/APIs/isTelephone.md @@ -9,7 +9,7 @@ val,任意类型 - locale,可选参数,默认值 'ZHCN' + locale,可选参数,默认值 'zh-CN' #### 说明: @@ -26,5 +26,10 @@ ```javascript jxmValidator.isTelephone('7632614'); // => true jxmValidator.isTelephone('0550-7632614'); // => true + jxmValidator.isTelephone('185055059334'); // => false + +jxmValidator.isTelephone(7632614); // => false + +jxmValidator.isTelephone('7632614', 'en-US'); // => false ``` diff --git a/docs/en-US/APIs/isUnEmptyString.md b/docs/en-US/APIs/isUnEmptyString.md index 99abcaf..88376e3 100644 --- a/docs/en-US/APIs/isUnEmptyString.md +++ b/docs/en-US/APIs/isUnEmptyString.md @@ -15,7 +15,9 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式,默认采用严格模式 + 该接口存在两种模式, 即严格模式、非严格模式 + + 默认采用 `严格模式` 若参数 `val` 不是 string, 则直接返回 false 若参数 `val` 是 string 并且不为空(''), 则返回 true, 否则返回 false @@ -32,11 +34,18 @@ #### 示例: ```javascript +jxmValidator.isUnEmptyString(3); // => false jxmValidator.isUnEmptyString('3'); // => true +jxmValidator.isUnEmptyString(0); // => false jxmValidator.isUnEmptyString(''); // => false jxmValidator.isUnEmptyString('', {isStrict: false})); // => false jxmValidator.isUnEmptyString(' '); // => 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 4b0065b..3bd81b5 100644 --- a/docs/en-US/APIs/isUnNegativeInteger.md +++ b/docs/en-US/APIs/isUnNegativeInteger.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是非负整数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为非负整数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,19 +38,35 @@ ```javascript jxmValidator.isUnNegativeInteger(3); // => true jxmValidator.isUnNegativeInteger('3'); // => true -jxmValidator.isUnNegativeInteger(3.3); // => false -jxmValidator.isUnNegativeInteger('3.3'); // => false +jxmValidator.isUnNegativeInteger(3, {isStrict: true}); // => true +jxmValidator.isUnNegativeInteger('3', {isStrict: true}); // => false + +jxmValidator.isUnNegativeInteger(0); // => true +jxmValidator.isUnNegativeIntegerv('0'); // => true +jxmValidator.isUnNegativeInteger(0, {isStrict: true}); // => true +jxmValidator.isUnNegativeInteger('0', {isStrict: true}); // => false jxmValidator.isUnNegativeInteger(-3); // => false jxmValidator.isUnNegativeInteger('-3'); // => false -jxmValidator.isUnNegativeInteger(-3.3); // => false -jxmValidator.isUnNegativeInteger('-3.3'); // => false +jxmValidator.isUnNegativeInteger(-3, {isStrict: true}); // => 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', {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(0); // => true -jxmValidator.isUnNegativeIntegerv('0'); // => true +jxmValidator.isUnNegativeInteger(''); // => false +jxmValidator.isUnNegativeInteger(' '); // => false +jxmValidator.isUnNegativeInteger(null); // => false +jxmValidator.isUnNegativeInteger(undefined); // => false + +jxmValidator.isUnNegativeInteger(NaN); // => false +jxmValidator.isUnNegativeInteger(Number.POSITIVE_INFINITY); // => false +jxmValidator.isUnNegativeInteger(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/en-US/APIs/isUnNegativeNumber.md b/docs/en-US/APIs/isUnNegativeNumber.md index 973f6b6..f5ec662 100644 --- a/docs/en-US/APIs/isUnNegativeNumber.md +++ b/docs/en-US/APIs/isUnNegativeNumber.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是非负数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为非负数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,11 +38,25 @@ s ```javascript jxmValidator.isUnNegativeNumber(3); // => true jxmValidator.isUnNegativeNumber('3'); // => true +jxmValidator.isUnNegativeNumber(3, {isStrict: true}); // => true jxmValidator.isUnNegativeNumber('3', {isStrict: true}); // => false jxmValidator.isUnNegativeNumber(0); // => true jxmValidator.isUnNegativeNumber('0'); // => true +jxmValidator.isUnNegativeNumber(0, {isStrict: true}); // => true +jxmValidator.isUnNegativeNumber('0', {isStrict: true}); // => false jxmValidator.isUnNegativeNumber(-3); // => false jxmValidator.isUnNegativeNumber('-3'); // => false +jxmValidator.isUnNegativeNumber(-3, {isStrict: true}); // => false +jxmValidator.isUnNegativeNumber('-3', {isStrict: true}); // => false + +jxmValidator.isUnNegativeNumber(''); // => false +jxmValidator.isUnNegativeNumber(' '); // => false +jxmValidator.isUnNegativeNumber(null); // => false +jxmValidator.isUnNegativeNumber(undefined); // => false + +jxmValidator.isUnNegativeNumber(NaN); // => false +jxmValidator.isUnNegativeNumber(Number.POSITIVE_INFINITY); // => false +jxmValidator.isUnNegativeNumber(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/en-US/APIs/isUnPositiveInteger.md b/docs/en-US/APIs/isUnPositiveInteger.md index 6f1f1ce..2505a6d 100644 --- a/docs/en-US/APIs/isUnPositiveInteger.md +++ b/docs/en-US/APIs/isUnPositiveInteger.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是非正整数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为非正整数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,19 +38,35 @@ ```javascript jxmValidator.isUnPositiveInteger(3); // => false jxmValidator.isUnPositiveInteger('3'); // => false -jxmValidator.isUnPositiveInteger(3.3); // => false -jxmValidator.isUnPositiveInteger('3.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); // => true jxmValidator.isUnPositiveInteger('-3'); // => true -jxmValidator.isUnPositiveInteger(-3.3); // => false -jxmValidator.isUnPositiveInteger('-3.3'); // => false +jxmValidator.isUnPositiveInteger(-3, {isStrict: true}); // => true +jxmValidator.isUnPositiveInteger('-3', {isStrict: true}); // => false -jxmValidator.isUnPositiveInteger('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('-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(''); // => false +jxmValidator.isUnPositiveInteger(' '); // => false +jxmValidator.isUnPositiveInteger(null); // => false +jxmValidator.isUnPositiveInteger(undefined); // => false + +jxmValidator.isUnPositiveInteger(NaN); // => false +jxmValidator.isUnPositiveInteger(Number.POSITIVE_INFINITY); // => false +jxmValidator.isUnPositiveInteger(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/en-US/APIs/isUnPositiveNumber.md b/docs/en-US/APIs/isUnPositiveNumber.md index 189d77f..364340e 100644 --- a/docs/en-US/APIs/isUnPositiveNumber.md +++ b/docs/en-US/APIs/isUnPositiveNumber.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是非正数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为非正数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,11 +38,25 @@ ```javascript jxmValidator.isUnPositiveNumber(-3); // => true jxmValidator.isUnPositiveNumber('-3'); // => true +jxmValidator.isUnPositiveNumber(-3, {isStrict: true}); // => true jxmValidator.isUnPositiveNumber('-3', {isStrict: true}); // => false jxmValidator.isUnPositiveNumber(0); // => true jxmValidator.isUnPositiveNumber('0'); // => true +jxmValidator.isUnPositiveNumber(0, {isStrict: true}); // => true +jxmValidator.isUnPositiveNumber('0', {isStrict: true}); // => false jxmValidator.isUnPositiveNumber(3); // => false jxmValidator.isUnPositiveNumber('3'); // => false +jxmValidator.isUnPositiveNumber(3, {isStrict: true}); // => false +jxmValidator.isUnPositiveNumber('3', {isStrict: true}); // => false + +jxmValidator.isUnPositiveNumber(''); // => false +jxmValidator.isUnPositiveNumber(' '); // => false +jxmValidator.isUnPositiveNumber(null); // => false +jxmValidator.isUnPositiveNumber(undefined); // => false + +jxmValidator.isUnPositiveNumber(NaN); // => false +jxmValidator.isUnPositiveNumber(Number.POSITIVE_INFINITY); // => false +jxmValidator.isUnPositiveNumber(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/en-US/APIs/isUnZero.md b/docs/en-US/APIs/isUnZero.md index eed4eaa..a10adb3 100644 --- a/docs/en-US/APIs/isUnZero.md +++ b/docs/en-US/APIs/isUnZero.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且不是 NaN, Infinity, -Infinity, 同时也不等于零, 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且经过 ToNumber 转换为非 NaN, Infinity, -Infinity 的数字, 同时也不等于零, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -33,6 +37,7 @@ ```javascript jxmValidator.isUnZero(3); // => true +jxmValidator.isUnZero(-3); // => true jxmValidator.isUnZero('3'); // => true jxmValidator.isUnZero('3', {isStrict: true}); // => false @@ -45,6 +50,7 @@ jxmValidator.isUnZero(Number.POSITIVE_INFINITY); // => false jxmValidator.isUnZero(Number.NEGATIVE_INFINITY); // => false jxmValidator.isUnZero(''); // => false +jxmValidator.isUnZero(' '); // => false jxmValidator.isUnZero(null); // => false jxmValidator.isUnZero(undefined); // => false diff --git a/docs/en-US/APIs/isUndefined.md b/docs/en-US/APIs/isUndefined.md index bc1683d..98005b9 100644 --- a/docs/en-US/APIs/isUndefined.md +++ b/docs/en-US/APIs/isUndefined.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val === undefined 时,返回 `true`, 否则返回 `false` + 当且仅当参数 val === undefined 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/en-US/APIs/isZero.md b/docs/en-US/APIs/isZero.md index c3c720e..ada2ed1 100644 --- a/docs/en-US/APIs/isZero.md +++ b/docs/en-US/APIs/isZero.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且等于零, 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且经过 ToNumber 转换后的数据等于零, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -33,6 +37,7 @@ ```javascript jxmValidator.isZero(3); // => false +jxmValidator.isZero(-3); // => false jxmValidator.isZero(0); // => true jxmValidator.isZero('0'); // => true jxmValidator.isZero('0', {isStrict: true}); // => false @@ -42,6 +47,7 @@ jxmValidator.isZero(Number.POSITIVE_INFINITY); // => false jxmValidator.isZero(Number.NEGATIVE_INFINITY); // => false jxmValidator.isZero(''); // => false +jxmValidator.isZero(' '); // => false jxmValidator.isZero(null); // => false jxmValidator.isZero(undefined); // => false diff --git a/docs/zh-CN/APIs.md b/docs/zh-CN/APIs.md index 0e105f1..c1f89cb 100644 --- a/docs/zh-CN/APIs.md +++ b/docs/zh-CN/APIs.md @@ -2,9 +2,10 @@ API 文档 =========================== -假设,您已经阅读,并且已经知道如何使用,可以直接跳过该步骤。如果还没有看过的同学,请看这里,引入`jxm-validator`: +假设,您已经阅读,并且知道如何使用,可以直接跳过该步骤。若是还没有看过的同学,请看这里: ```javascript + // 引入 `jxm-validator` const jxmValidator = require('jxm-validator'); jxmValidator.isNull(null); diff --git a/docs/zh-CN/APIs/isArray.md b/docs/zh-CN/APIs/isArray.md index 8844448..28b2cc5 100644 --- a/docs/zh-CN/APIs/isArray.md +++ b/docs/zh-CN/APIs/isArray.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val 为 `array` 时,返回 `true`, 否则返回 `false` + 当参数 val 为 `array` 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/zh-CN/APIs/isBoolean.md b/docs/zh-CN/APIs/isBoolean.md index 7dfcf93..88f36fd 100644 --- a/docs/zh-CN/APIs/isBoolean.md +++ b/docs/zh-CN/APIs/isBoolean.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val 为 `boolean` 时,返回 `true`, 否则返回 `false` + 当参数 val 为 `boolean` 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/zh-CN/APIs/isEmail.md b/docs/zh-CN/APIs/isEmail.md index 268c077..1fc1837 100644 --- a/docs/zh-CN/APIs/isEmail.md +++ b/docs/zh-CN/APIs/isEmail.md @@ -22,4 +22,5 @@ jxmValidator.isEmail('575099329@qq'); // => false jxmValidator.isEmail('dotx575099329@gmail.com'); // => true jxmValidator.isEmail('dotx575099329@163.com'); // => true jxmValidator.isEmail('dotx575099329@qingniu.co'); // => true +jxmValidator.isEmail(333); // => false ``` diff --git a/docs/zh-CN/APIs/isEmptyString.md b/docs/zh-CN/APIs/isEmptyString.md index 626e63f..68731e0 100644 --- a/docs/zh-CN/APIs/isEmptyString.md +++ b/docs/zh-CN/APIs/isEmptyString.md @@ -15,7 +15,9 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式,默认采用严格模式 + 该接口存在两种模式, 即严格模式、非严格模式 + + 默认采用 `严格模式` 若参数 `val` 不是 string, 则直接返回 false 若参数 `val` 是 string 并且为空(''), 则返回 true, 否则返回 false @@ -32,11 +34,19 @@ #### 示例: ```javascript +jxmValidator.isEmptyString(3); // => false jxmValidator.isEmptyString('3'); // => false +jxmValidator.isEmptyString(0); // => false + jxmValidator.isEmptyString(''); // => true jxmValidator.isEmptyString('', {isStrict: false})); // => true jxmValidator.isEmptyString(' '); // => 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/isFunction.md b/docs/zh-CN/APIs/isFunction.md index 6617dbe..8aceca3 100644 --- a/docs/zh-CN/APIs/isFunction.md +++ b/docs/zh-CN/APIs/isFunction.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val 为 `function` 时,返回 `true`, 否则返回 `false` + 当参数 val 为 `function` 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/zh-CN/APIs/isInfinity.md b/docs/zh-CN/APIs/isInfinity.md index e58de7c..33412c2 100644 --- a/docs/zh-CN/APIs/isInfinity.md +++ b/docs/zh-CN/APIs/isInfinity.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val 为 `Infinity` 或 `-Infinity` 时,返回 `true`, 否则返回 `false` + 当且仅当参数 val 为 `Infinity` 或 `-Infinity` 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/zh-CN/APIs/isInteger.md b/docs/zh-CN/APIs/isInteger.md index 4c5a007..60d05eb 100644 --- a/docs/zh-CN/APIs/isInteger.md +++ b/docs/zh-CN/APIs/isInteger.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是整数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为整数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,19 +38,35 @@ ```javascript jxmValidator.isInteger(3); // => true jxmValidator.isInteger('3'); // => true -jxmValidator.isInteger(3.3); // => false -jxmValidator.isInteger('3.3'); // => false +jxmValidator.isInteger(3, {isStrict: true}); // => true +jxmValidator.isInteger('3', {isStrict: true}); // => false + +jxmValidator.isInteger(0); // => true +jxmValidator.isInteger('0'); // => true +jxmValidator.isInteger(0, {isStrict: true}); // => true +jxmValidator.isInteger('0', {isStrict: true}); // => false jxmValidator.isInteger(-3); // => true jxmValidator.isInteger('-3'); // => true -jxmValidator.isInteger(-3.3); // => false -jxmValidator.isInteger('-3.3'); // => false +jxmValidator.isInteger(-3, {isStrict: true}); // => true +jxmValidator.isInteger('-3', {isStrict: true}); // => false -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', {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(0); // => true -jxmValidator.isInteger('0'); // => true +jxmValidator.isInteger(''); // => false +jxmValidator.isInteger(' '); // => false +jxmValidator.isInteger(null); // => false +jxmValidator.isInteger(undefined); // => false + +jxmValidator.isInteger(NaN); // => false +jxmValidator.isInteger(Number.POSITIVE_INFINITY); // => false +jxmValidator.isInteger(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/zh-CN/APIs/isJSON.md b/docs/zh-CN/APIs/isJSON.md index 470c79d..e010a72 100644 --- a/docs/zh-CN/APIs/isJSON.md +++ b/docs/zh-CN/APIs/isJSON.md @@ -17,6 +17,7 @@ ```javascript jxmValidator.isJSON('{"a": 3}'); // => true +jxmValidator.isJSON('{a: 3}'); // => false jxmValidator.isJSON('[3, 4]'); // => false jxmValidator.isJSON('3'); // => false diff --git a/docs/zh-CN/APIs/isMobile.md b/docs/zh-CN/APIs/isMobile.md index c2c804b..5635b1e 100644 --- a/docs/zh-CN/APIs/isMobile.md +++ b/docs/zh-CN/APIs/isMobile.md @@ -9,7 +9,7 @@ val,任意类型 - locale,可选参数,默认值 'ZHCN' + locale,可选参数,默认值 'zh-CN' #### 说明: @@ -26,8 +26,14 @@ ```javascript jxmValidator.isMobile('18505505933'); // => true jxmValidator.isMobile('28505505933'); // => false + jxmValidator.isMobile('185055059334'); // => false jxmValidator.isMobile('1850550593'); // => false + jxmValidator.isMobile('1850550 933'); // => false jxmValidator.isMobile('1850550-933'); // => false + +jxmValidator.isMobile(18505505933); // => false + +jxmValidator.isMobile('18505505933', 'en-US'); // => false ``` diff --git a/docs/zh-CN/APIs/isNaN.md b/docs/zh-CN/APIs/isNaN.md index b2d8770..dcc2c87 100644 --- a/docs/zh-CN/APIs/isNaN.md +++ b/docs/zh-CN/APIs/isNaN.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val 为 `NaN` 时,返回 `true`, 否则返回 `false` + 当且仅当参数 val 为 `NaN` 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/zh-CN/APIs/isNegativeInteger.md b/docs/zh-CN/APIs/isNegativeInteger.md index 481a64e..95ee1d8 100644 --- a/docs/zh-CN/APIs/isNegativeInteger.md +++ b/docs/zh-CN/APIs/isNegativeInteger.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是负整数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为负整数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,19 +38,35 @@ ```javascript jxmValidator.isNegativeInteger(3); // => false jxmValidator.isNegativeInteger('3'); // => false -jxmValidator.isNegativeInteger(3.3); // => false -jxmValidator.isNegativeInteger('3.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); // => true jxmValidator.isNegativeInteger('-3'); // => true -jxmValidator.isNegativeInteger(-3.3); // => false -jxmValidator.isNegativeInteger('-3.3'); // => false +jxmValidator.isNegativeInteger(-3, {isStrict: true}); // => true +jxmValidator.isNegativeInteger('-3', {isStrict: true}); // => false -jxmValidator.isNegativeInteger('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('-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(''); // => false +jxmValidator.isNegativeInteger(' '); // => false +jxmValidator.isNegativeInteger(null); // => false +jxmValidator.isNegativeInteger(undefined); // => false + +jxmValidator.isNegativeInteger(NaN); // => false +jxmValidator.isNegativeInteger(Number.POSITIVE_INFINITY); // => false +jxmValidator.isNegativeInteger(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/zh-CN/APIs/isNegativeNumber.md b/docs/zh-CN/APIs/isNegativeNumber.md index 730c997..867576d 100644 --- a/docs/zh-CN/APIs/isNegativeNumber.md +++ b/docs/zh-CN/APIs/isNegativeNumber.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是负数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为负数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,11 +38,25 @@ ```javascript jxmValidator.isNegativeNumber(-3); // => true jxmValidator.isNegativeNumber('-3'); // => true +jxmValidator.isNegativeNumber(-3, {isStrict: true}); // => true jxmValidator.isNegativeNumber('-3', {isStrict: true}); // => false jxmValidator.isNegativeNumber(0); // => false jxmValidator.isNegativeNumber('0'); // => false +jxmValidator.isNegativeNumber(0, {isStrict: true}); // => false +jxmValidator.isNegativeNumber('0', {isStrict: true}); // => false jxmValidator.isNegativeNumber(3); // => false jxmValidator.isNegativeNumber('3'); // => false +jxmValidator.isNegativeNumber(3, {isStrict: true}); // => false +jxmValidator.isNegativeNumber('3', {isStrict: true}); // => false + +jxmValidator.isNegativeNumber(''); // => false +jxmValidator.isNegativeNumber(' '); // => false +jxmValidator.isNegativeNumber(null); // => false +jxmValidator.isNegativeNumber(undefined); // => false + +jxmValidator.isNegativeNumber(NaN); // => false +jxmValidator.isNegativeNumber(Number.POSITIVE_INFINITY); // => false +jxmValidator.isNegativeNumber(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/zh-CN/APIs/isNil.md b/docs/zh-CN/APIs/isNil.md index 8e2377a..34dc0d4 100644 --- a/docs/zh-CN/APIs/isNil.md +++ b/docs/zh-CN/APIs/isNil.md @@ -11,7 +11,7 @@ #### 说明: - 当参数 val === null 或者 val === undefined 时,返回 `true`, 否则返回 `false` + 当且仅当参数 val === null 或者 val === undefined 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/zh-CN/APIs/isNull.md b/docs/zh-CN/APIs/isNull.md index cb93469..716af9e 100644 --- a/docs/zh-CN/APIs/isNull.md +++ b/docs/zh-CN/APIs/isNull.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val === null 时,返回 `true`, 否则返回 `false` + 当且仅当参数 val === null 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/zh-CN/APIs/isNumber.md b/docs/zh-CN/APIs/isNumber.md index 414a6a8..27da65c 100644 --- a/docs/zh-CN/APIs/isNumber.md +++ b/docs/zh-CN/APIs/isNumber.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val 为 `number` 时,返回 `true`, 否则返回 `false` + 当参数 val 为 `number` 时,返回 `true`, 否则返回 `false` * number 类型还包括: NaN, Infinity, -Infinity diff --git a/docs/zh-CN/APIs/isNumeric.md b/docs/zh-CN/APIs/isNumeric.md index 64251a8..d252f81 100644 --- a/docs/zh-CN/APIs/isNumeric.md +++ b/docs/zh-CN/APIs/isNumeric.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且不是 NaN, Infinity, -Infinity, 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且可以经过 ToNumber 转换为非 NaN, Infinity, -Infinity 的数字, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,6 +38,7 @@ ```javascript jxmValidator.isNumeric(3); // => true jxmValidator.isNumeric('3'); // => true +jxmValidator.isNumeric(3, {isStrict: true}); // => true jxmValidator.isNumeric('3', {isStrict: true}); // => false jxmValidator.isNumeric('3a'); // => false @@ -42,6 +47,7 @@ jxmValidator.isNumeric(Number.POSITIVE_INFINITY); // => false jxmValidator.isNumeric(Number.NEGATIVE_INFINITY); // => false jxmValidator.isNumeric(''); // => false +jxmValidator.isNumeric(' '); // => false jxmValidator.isNumeric(null); // => false jxmValidator.isNumeric(undefined); // => false diff --git a/docs/zh-CN/APIs/isObject.md b/docs/zh-CN/APIs/isObject.md index a4b1aee..ffa0379 100644 --- a/docs/zh-CN/APIs/isObject.md +++ b/docs/zh-CN/APIs/isObject.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val 为 `object` 时,返回 `true`, 否则返回 `false` + 当参数 val 为 `object` 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/zh-CN/APIs/isPhone.md b/docs/zh-CN/APIs/isPhone.md index d091425..bbc72c5 100644 --- a/docs/zh-CN/APIs/isPhone.md +++ b/docs/zh-CN/APIs/isPhone.md @@ -9,7 +9,7 @@ val,任意类型 - locale,可选参数,默认值 'ZHCN' + locale,可选参数,默认值 'zh-CN' #### 说明: diff --git a/docs/zh-CN/APIs/isPositiveInteger.md b/docs/zh-CN/APIs/isPositiveInteger.md index 3216ab8..9df6985 100644 --- a/docs/zh-CN/APIs/isPositiveInteger.md +++ b/docs/zh-CN/APIs/isPositiveInteger.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是正整数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为正整数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,19 +38,35 @@ ```javascript jxmValidator.isPositiveInteger(3); // => true jxmValidator.isPositiveInteger('3'); // => true -jxmValidator.isPositiveInteger(3.3); // => false -jxmValidator.isPositiveInteger('3.3'); // => false +jxmValidator.isPositiveInteger(3, {isStrict: true}); // => true +jxmValidator.isPositiveInteger('3', {isStrict: true}); // => false + +jxmValidator.isPositiveInteger(0); // => false +jxmValidator.isPositiveInteger('0'); // => false +jxmValidator.isPositiveInteger(0, {isStrict: true}); // => false +jxmValidator.isPositiveInteger('0', {isStrict: true}); // => false jxmValidator.isPositiveInteger(-3); // => false jxmValidator.isPositiveInteger('-3'); // => false -jxmValidator.isPositiveInteger(-3.3); // => false -jxmValidator.isPositiveInteger('-3.3'); // => false +jxmValidator.isPositiveInteger(-3, {isStrict: true}); // => 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', {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(0); // => false -jxmValidator.isPositiveInteger('0'); // => false +jxmValidator.isPositiveInteger(''); // => false +jxmValidator.isPositiveInteger(' '); // => false +jxmValidator.isPositiveInteger(null); // => false +jxmValidator.isPositiveInteger(undefined); // => false + +jxmValidator.isPositiveInteger(NaN); // => false +jxmValidator.isPositiveInteger(Number.POSITIVE_INFINITY); // => false +jxmValidator.isPositiveInteger(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/zh-CN/APIs/isPositiveNumber.md b/docs/zh-CN/APIs/isPositiveNumber.md index 81e5eff..a29a723 100644 --- a/docs/zh-CN/APIs/isPositiveNumber.md +++ b/docs/zh-CN/APIs/isPositiveNumber.md @@ -3,7 +3,7 @@ #### 描述: - 校验参数 `val` 是否为正整数 + 校验参数 `val` 是否为正数 #### 参数: @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是正数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为正数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,11 +38,25 @@ ```javascript jxmValidator.isPositiveNumber(3); // => true jxmValidator.isPositiveNumber('3'); // => true +jxmValidator.isPositiveNumber(3, {isStrict: true}); // => true jxmValidator.isPositiveNumber('3', {isStrict: true}); // => false jxmValidator.isPositiveNumber(0); // => false jxmValidator.isPositiveNumber('0'); // => false +jxmValidator.isPositiveNumber(0, {isStrict: true}); // => false +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(''); // => false +jxmValidator.isPositiveNumber(' '); // => false +jxmValidator.isPositiveNumber(null); // => false +jxmValidator.isPositiveNumber(undefined); // => false + +jxmValidator.isPositiveNumber(NaN); // => false +jxmValidator.isPositiveNumber(Number.POSITIVE_INFINITY); // => false +jxmValidator.isPositiveNumber(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/zh-CN/APIs/isRealNumber.md b/docs/zh-CN/APIs/isRealNumber.md index ee0808b..beb5fd7 100644 --- a/docs/zh-CN/APIs/isRealNumber.md +++ b/docs/zh-CN/APIs/isRealNumber.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且不是 NaN, 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且可以经过 ToNumber 转换为非 NaN 的数字, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,6 +38,7 @@ ```javascript jxmValidator.isRealNumber(3); // => true jxmValidator.isRealNumber('3'); // => true +jxmValidator.isRealNumber(3, {isStrict: true}); // => true jxmValidator.isRealNumber('3', {isStrict: true}); // => false jxmValidator.isRealNumber('3a'); // => false @@ -42,6 +47,7 @@ jxmValidator.isRealNumber(Number.POSITIVE_INFINITY); // => true jxmValidator.isRealNumber(Number.NEGATIVE_INFINITY); // => true jxmValidator.isRealNumber(''); // => false +jxmValidator.isRealNumber(' '); // => false jxmValidator.isRealNumber(null); // => false jxmValidator.isRealNumber(undefined); // => false diff --git a/docs/zh-CN/APIs/isString.md b/docs/zh-CN/APIs/isString.md index e9d0f60..f3a8674 100644 --- a/docs/zh-CN/APIs/isString.md +++ b/docs/zh-CN/APIs/isString.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val 为 `string` 时,返回 `true`, 否则返回 `false` + 当参数 val 为 `string` 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/zh-CN/APIs/isTelephone.md b/docs/zh-CN/APIs/isTelephone.md index cd1a1d0..ecccace 100644 --- a/docs/zh-CN/APIs/isTelephone.md +++ b/docs/zh-CN/APIs/isTelephone.md @@ -9,7 +9,7 @@ val,任意类型 - locale,可选参数,默认值 'ZHCN' + locale,可选参数,默认值 'zh-CN' #### 说明: @@ -26,5 +26,10 @@ ```javascript jxmValidator.isTelephone('7632614'); // => true jxmValidator.isTelephone('0550-7632614'); // => true + jxmValidator.isTelephone('185055059334'); // => false + +jxmValidator.isTelephone(7632614); // => false + +jxmValidator.isTelephone('7632614', 'en-US'); // => false ``` diff --git a/docs/zh-CN/APIs/isUnEmptyString.md b/docs/zh-CN/APIs/isUnEmptyString.md index 99abcaf..88376e3 100644 --- a/docs/zh-CN/APIs/isUnEmptyString.md +++ b/docs/zh-CN/APIs/isUnEmptyString.md @@ -15,7 +15,9 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式,默认采用严格模式 + 该接口存在两种模式, 即严格模式、非严格模式 + + 默认采用 `严格模式` 若参数 `val` 不是 string, 则直接返回 false 若参数 `val` 是 string 并且不为空(''), 则返回 true, 否则返回 false @@ -32,11 +34,18 @@ #### 示例: ```javascript +jxmValidator.isUnEmptyString(3); // => false jxmValidator.isUnEmptyString('3'); // => true +jxmValidator.isUnEmptyString(0); // => false jxmValidator.isUnEmptyString(''); // => false jxmValidator.isUnEmptyString('', {isStrict: false})); // => false jxmValidator.isUnEmptyString(' '); // => 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 4b0065b..3bd81b5 100644 --- a/docs/zh-CN/APIs/isUnNegativeInteger.md +++ b/docs/zh-CN/APIs/isUnNegativeInteger.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是非负整数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为非负整数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,19 +38,35 @@ ```javascript jxmValidator.isUnNegativeInteger(3); // => true jxmValidator.isUnNegativeInteger('3'); // => true -jxmValidator.isUnNegativeInteger(3.3); // => false -jxmValidator.isUnNegativeInteger('3.3'); // => false +jxmValidator.isUnNegativeInteger(3, {isStrict: true}); // => true +jxmValidator.isUnNegativeInteger('3', {isStrict: true}); // => false + +jxmValidator.isUnNegativeInteger(0); // => true +jxmValidator.isUnNegativeIntegerv('0'); // => true +jxmValidator.isUnNegativeInteger(0, {isStrict: true}); // => true +jxmValidator.isUnNegativeInteger('0', {isStrict: true}); // => false jxmValidator.isUnNegativeInteger(-3); // => false jxmValidator.isUnNegativeInteger('-3'); // => false -jxmValidator.isUnNegativeInteger(-3.3); // => false -jxmValidator.isUnNegativeInteger('-3.3'); // => false +jxmValidator.isUnNegativeInteger(-3, {isStrict: true}); // => 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', {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(0); // => true -jxmValidator.isUnNegativeIntegerv('0'); // => true +jxmValidator.isUnNegativeInteger(''); // => false +jxmValidator.isUnNegativeInteger(' '); // => false +jxmValidator.isUnNegativeInteger(null); // => false +jxmValidator.isUnNegativeInteger(undefined); // => false + +jxmValidator.isUnNegativeInteger(NaN); // => false +jxmValidator.isUnNegativeInteger(Number.POSITIVE_INFINITY); // => false +jxmValidator.isUnNegativeInteger(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/zh-CN/APIs/isUnNegativeNumber.md b/docs/zh-CN/APIs/isUnNegativeNumber.md index 973f6b6..f5ec662 100644 --- a/docs/zh-CN/APIs/isUnNegativeNumber.md +++ b/docs/zh-CN/APIs/isUnNegativeNumber.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是非负数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为非负数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,11 +38,25 @@ s ```javascript jxmValidator.isUnNegativeNumber(3); // => true jxmValidator.isUnNegativeNumber('3'); // => true +jxmValidator.isUnNegativeNumber(3, {isStrict: true}); // => true jxmValidator.isUnNegativeNumber('3', {isStrict: true}); // => false jxmValidator.isUnNegativeNumber(0); // => true jxmValidator.isUnNegativeNumber('0'); // => true +jxmValidator.isUnNegativeNumber(0, {isStrict: true}); // => true +jxmValidator.isUnNegativeNumber('0', {isStrict: true}); // => false jxmValidator.isUnNegativeNumber(-3); // => false jxmValidator.isUnNegativeNumber('-3'); // => false +jxmValidator.isUnNegativeNumber(-3, {isStrict: true}); // => false +jxmValidator.isUnNegativeNumber('-3', {isStrict: true}); // => false + +jxmValidator.isUnNegativeNumber(''); // => false +jxmValidator.isUnNegativeNumber(' '); // => false +jxmValidator.isUnNegativeNumber(null); // => false +jxmValidator.isUnNegativeNumber(undefined); // => false + +jxmValidator.isUnNegativeNumber(NaN); // => false +jxmValidator.isUnNegativeNumber(Number.POSITIVE_INFINITY); // => false +jxmValidator.isUnNegativeNumber(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/zh-CN/APIs/isUnPositiveInteger.md b/docs/zh-CN/APIs/isUnPositiveInteger.md index 6f1f1ce..2505a6d 100644 --- a/docs/zh-CN/APIs/isUnPositiveInteger.md +++ b/docs/zh-CN/APIs/isUnPositiveInteger.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是非正整数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为非正整数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,19 +38,35 @@ ```javascript jxmValidator.isUnPositiveInteger(3); // => false jxmValidator.isUnPositiveInteger('3'); // => false -jxmValidator.isUnPositiveInteger(3.3); // => false -jxmValidator.isUnPositiveInteger('3.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); // => true jxmValidator.isUnPositiveInteger('-3'); // => true -jxmValidator.isUnPositiveInteger(-3.3); // => false -jxmValidator.isUnPositiveInteger('-3.3'); // => false +jxmValidator.isUnPositiveInteger(-3, {isStrict: true}); // => true +jxmValidator.isUnPositiveInteger('-3', {isStrict: true}); // => false -jxmValidator.isUnPositiveInteger('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('-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(''); // => false +jxmValidator.isUnPositiveInteger(' '); // => false +jxmValidator.isUnPositiveInteger(null); // => false +jxmValidator.isUnPositiveInteger(undefined); // => false + +jxmValidator.isUnPositiveInteger(NaN); // => false +jxmValidator.isUnPositiveInteger(Number.POSITIVE_INFINITY); // => false +jxmValidator.isUnPositiveInteger(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/zh-CN/APIs/isUnPositiveNumber.md b/docs/zh-CN/APIs/isUnPositiveNumber.md index 189d77f..364340e 100644 --- a/docs/zh-CN/APIs/isUnPositiveNumber.md +++ b/docs/zh-CN/APIs/isUnPositiveNumber.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且是非正数 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且通过验证为非正数字符串, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -34,11 +38,25 @@ ```javascript jxmValidator.isUnPositiveNumber(-3); // => true jxmValidator.isUnPositiveNumber('-3'); // => true +jxmValidator.isUnPositiveNumber(-3, {isStrict: true}); // => true jxmValidator.isUnPositiveNumber('-3', {isStrict: true}); // => false jxmValidator.isUnPositiveNumber(0); // => true jxmValidator.isUnPositiveNumber('0'); // => true +jxmValidator.isUnPositiveNumber(0, {isStrict: true}); // => true +jxmValidator.isUnPositiveNumber('0', {isStrict: true}); // => false jxmValidator.isUnPositiveNumber(3); // => false jxmValidator.isUnPositiveNumber('3'); // => false +jxmValidator.isUnPositiveNumber(3, {isStrict: true}); // => false +jxmValidator.isUnPositiveNumber('3', {isStrict: true}); // => false + +jxmValidator.isUnPositiveNumber(''); // => false +jxmValidator.isUnPositiveNumber(' '); // => false +jxmValidator.isUnPositiveNumber(null); // => false +jxmValidator.isUnPositiveNumber(undefined); // => false + +jxmValidator.isUnPositiveNumber(NaN); // => false +jxmValidator.isUnPositiveNumber(Number.POSITIVE_INFINITY); // => false +jxmValidator.isUnPositiveNumber(Number.NEGATIVE_INFINITY); // => false ``` diff --git a/docs/zh-CN/APIs/isUnZero.md b/docs/zh-CN/APIs/isUnZero.md index eed4eaa..a10adb3 100644 --- a/docs/zh-CN/APIs/isUnZero.md +++ b/docs/zh-CN/APIs/isUnZero.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且不是 NaN, Infinity, -Infinity, 同时也不等于零, 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且经过 ToNumber 转换为非 NaN, Infinity, -Infinity 的数字, 同时也不等于零, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -33,6 +37,7 @@ ```javascript jxmValidator.isUnZero(3); // => true +jxmValidator.isUnZero(-3); // => true jxmValidator.isUnZero('3'); // => true jxmValidator.isUnZero('3', {isStrict: true}); // => false @@ -45,6 +50,7 @@ jxmValidator.isUnZero(Number.POSITIVE_INFINITY); // => false jxmValidator.isUnZero(Number.NEGATIVE_INFINITY); // => false jxmValidator.isUnZero(''); // => false +jxmValidator.isUnZero(' '); // => false jxmValidator.isUnZero(null); // => false jxmValidator.isUnZero(undefined); // => false diff --git a/docs/zh-CN/APIs/isUndefined.md b/docs/zh-CN/APIs/isUndefined.md index bc1683d..98005b9 100644 --- a/docs/zh-CN/APIs/isUndefined.md +++ b/docs/zh-CN/APIs/isUndefined.md @@ -11,7 +11,7 @@ #### 说明: - 仅当参数 val === undefined 时,返回 `true`, 否则返回 `false` + 当且仅当参数 val === undefined 时,返回 `true`, 否则返回 `false` #### 示例: diff --git a/docs/zh-CN/APIs/isZero.md b/docs/zh-CN/APIs/isZero.md index c3c720e..ada2ed1 100644 --- a/docs/zh-CN/APIs/isZero.md +++ b/docs/zh-CN/APIs/isZero.md @@ -15,12 +15,16 @@ #### 说明: - 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + 该接口存在两种模式, 即严格模式、非严格模式; + + 默认采用 `非严格模式` 若参数 `val` 为 number 类型, 并且等于零, 则返回 true, 否则返回 false 若参数 `val` 为 string 类型, 并且经过 ToNumber 转换后的数据等于零, 则返回 true, 否则返回 false 若参数 `val` 不属于以上两种类型, 则直接返回 false + 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false e.g. @@ -33,6 +37,7 @@ ```javascript jxmValidator.isZero(3); // => false +jxmValidator.isZero(-3); // => false jxmValidator.isZero(0); // => true jxmValidator.isZero('0'); // => true jxmValidator.isZero('0', {isStrict: true}); // => false @@ -42,6 +47,7 @@ jxmValidator.isZero(Number.POSITIVE_INFINITY); // => false jxmValidator.isZero(Number.NEGATIVE_INFINITY); // => false jxmValidator.isZero(''); // => false +jxmValidator.isZero(' '); // => false jxmValidator.isZero(null); // => false jxmValidator.isZero(undefined); // => false diff --git a/package.json b/package.json index 7849820..d4dae88 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,14 @@ "description": "A modern JavaScript verification toolkit library", "main": "validator.js", "scripts": { - "build": "npm run jxmEslint && npm run jxmCoverage && npm run jxmBuild", - "build:uglify": "npm run jxmEslint && npm run jxmCoverage && npm run jxmUglify", + "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 src --ignore-path .eslintignore" }, "repository": { diff --git a/src/internal/assertDataType.js b/src/internal/assertDataType.js index 78ce7c3..26aceaf 100644 --- a/src/internal/assertDataType.js +++ b/src/internal/assertDataType.js @@ -21,9 +21,9 @@ var DATA_TYPE_REPLACE_REX = /^\[object\u0020|\]$/ig; var _toString = Object.prototype.toString; /** - * 断言`val`的数据类型是否为`type`对应的数据类型 + * 断言 `val` 的数据类型是否为 `type` 对应的数据类型 * - * 若是参数`val`的数据类型与`type`相同,则返回 true, + * 若是参数 `val` 的数据类型与 `type` 相同,则返回 true, * * 若是不相同,则返回 false * diff --git a/src/isArray.js b/src/isArray.js index e23c0e1..c15b1d8 100644 --- a/src/isArray.js +++ b/src/isArray.js @@ -3,9 +3,9 @@ var DATA_TYPE_ENUM = require('./internal/enum/dataTypeEnum'); var assertDataType = require('./internal/assertDataType'); /** - * 校验 `val` 是否为 array + * 校验参数 `val` 是否为 array * - * 若是参数 `val` 的类型为 `[object Array]` 时,返回 true, + * 若参数 `val` 的类型为 `[object Array]` 时,返回 true, * * 否则, 返回 false * diff --git a/src/isBoolean.js b/src/isBoolean.js index d5d2f87..6a36709 100644 --- a/src/isBoolean.js +++ b/src/isBoolean.js @@ -3,9 +3,9 @@ var DATA_TYPE_ENUM = require('./internal/enum/dataTypeEnum'); var assertDataType = require('./internal/assertDataType'); /** - * 校验 `val` 是否为 boolean + * 校验参数 `val` 是否为 boolean * - * 若是参数 `val` 的类型为 `boolean` 或者 `[object Boolean]` 时, 返回 true, + * 若参数 `val` 的类型为 `boolean` 或者 `[object Boolean]` 时, 则返回 true, * * 否则, 返回 false * diff --git a/src/isEmail.js b/src/isEmail.js index 4197b4a..ea7247f 100644 --- a/src/isEmail.js +++ b/src/isEmail.js @@ -3,7 +3,7 @@ var _isString = require('./isString'); var REGEX_ENUM = require('./internal/enum/regexEnum'); /** - * 校验 `val` 是否为邮箱 + * 校验参数 `val` 是否为邮箱 * * 若参数 `val` 是邮箱, 则返回 true, 否则返回 false * diff --git a/src/isEmptyArray.js b/src/isEmptyArray.js index 36a82b2..9ea3a42 100644 --- a/src/isEmptyArray.js +++ b/src/isEmptyArray.js @@ -2,7 +2,7 @@ var _isArray = require('./isArray'); /** - * 校验 `val` 是否为空数组 + * 校验参数 `val` 是否为空数组 * * 若参数 `val` 不是 array, 则直接返回 false * 若参数 `val` 是 array, 并且为空,则返回 true, 否则, 返回 false diff --git a/src/isEmptyString.js b/src/isEmptyString.js index fdd1ee8..4e60ad0 100644 --- a/src/isEmptyString.js +++ b/src/isEmptyString.js @@ -3,9 +3,11 @@ var _isString = require('./isString'); var _isObject = require('./isObject'); /** - * 校验 `val` 是否为 空字符串 + * 校验参数 `val` 是否为 空字符串 * - * 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`严格模式` + * 该接口存在两种模式, 即严格模式、非严格模式; + * + * 默认采用 `严格模式` * * 若参数 `val` 不是 string, 则直接返回 false * 若参数 `val` 是 string, 并且为空,则返回 true, 否则, 返回 false @@ -13,10 +15,11 @@ var _isObject = require('./isObject'); * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, * 则会对参数 `val` 进行两端去除空白(空字符),之后在校验其是否为空字符串 * - * e.g + * e.g. + * * 待校验参数 ' ' - * 若是严格模式, 则该参数值校验后, 返回 true - * 若是非严格模式, 则该参数值校验后, 返回 false + * > 若是严格模式, 则该参数值校验后, 返回 true + * > 若是非严格模式, 则该参数值校验后, 返回 false * * @param {*} val 待校验的参数 * @param {Object} options 可选参数 diff --git a/src/isFunction.js b/src/isFunction.js index a14abf8..7d8322c 100644 --- a/src/isFunction.js +++ b/src/isFunction.js @@ -3,9 +3,9 @@ var DATA_TYPE_ENUM = require('./internal/enum/dataTypeEnum'); var assertDataType = require('./internal/assertDataType'); /** - * 校验 `val` 是否为 function + * 校验参数 `val` 是否为 function * - * 若是参数 `val` 的类型为 `[object Function]` 时,返回 true, + * 若参数 `val` 的类型为 `[object Function]` 时,返回 true, * * 否则, 返回 false * diff --git a/src/isInfinity.js b/src/isInfinity.js index 8366d06..69200ba 100644 --- a/src/isInfinity.js +++ b/src/isInfinity.js @@ -4,7 +4,7 @@ var POSITIVE_INFINITY = 1 / 0; var NEGATIVE_INFINITY = -1 / 0; /** - * 校验 `val` 是否为 Infinity, -Infinity + * 校验参数 `val` 是否为 Infinity, -Infinity * * 若参数 `val` 是 Infinity, -Infinity, 则返回 true, 否则返回 false * diff --git a/src/isInteger.js b/src/isInteger.js index 9f83a97..2037098 100644 --- a/src/isInteger.js +++ b/src/isInteger.js @@ -4,20 +4,25 @@ var _isObject = require('./isObject'); var REGEX_ENUM = require('./internal/enum/regexEnum'); /** - * 校验 `val` 是否为 整数 + * 校验参数 `val` 是否为 整数 * - * 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + * 该接口存在两种模式, 即严格模式、非严格模式; + * + * 默认采用 `非严格模式` * * 若参数 `val` 为 number 类型, 并且是整数 则返回 true, 否则返回 false * 若参数 `val` 为 string 类型, 并且通过验证为整数字符串, 则返回 true, 否则返回 false * 若参数 `val` 不属于以上两种类型, 则直接返回 false * + * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + * * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false * - * e.g + * e.g. + * * 待校验参数 '3' - * 若是严格模式, 则该参数值校验后, 返回 false - * 若是非严格模式, 则该参数值校验后, 返回 true + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true * * @param {*} val 待校验的参数 * @param {Object} options 可选参数 diff --git a/src/isJSON.js b/src/isJSON.js index 87ae2c2..a37cb00 100644 --- a/src/isJSON.js +++ b/src/isJSON.js @@ -3,7 +3,7 @@ var _isString = require('./isString'); var _isPlainObject = require('./isPlainObject'); /** - * 校验 `val` 是否为 JSON 对象 + * 校验参数 `val` 是否为 JSON 对象 * * 若参数 `val` 是 JSON 对象, 则返回 true, 否则返回 false * diff --git a/src/isMobile.js b/src/isMobile.js index 7ecd13a..a817c4d 100644 --- a/src/isMobile.js +++ b/src/isMobile.js @@ -4,7 +4,7 @@ var LOCALE_ENUM = require('./internal/enum/localeTypeEnum'); var REGEX_ENUM = require('./internal/enum/regexEnum'); /** - * 校验 `val` 是否为手机号码 + * 校验参数 `val` 是否为手机号码 * * 若参数 `val` 符合参数 `locale`(默认值: LOCALE_ENUM.ZHCN) 指定地区的手机号码格式, 则返回 true, 否则返回 false * diff --git a/src/isNaN.js b/src/isNaN.js index 9af177c..a4f66a1 100644 --- a/src/isNaN.js +++ b/src/isNaN.js @@ -1,6 +1,6 @@ /** - * 校验 `val` 是否为 NaN + * 校验参数 `val` 是否为 NaN * * 若参数 `val` 是 NaN,则返回 true,否则返回 false * diff --git a/src/isNegativeInteger.js b/src/isNegativeInteger.js index 7f34e34..1c62c41 100644 --- a/src/isNegativeInteger.js +++ b/src/isNegativeInteger.js @@ -4,20 +4,25 @@ var _isObject = require('./isObject'); var REGEX_ENUM = require('./internal/enum/regexEnum'); /** - * 校验 `val` 是否为 负整数 + * 校验参数 `val` 是否为 负整数 * - * 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + * 该接口存在两种模式, 即严格模式、非严格模式; + * + * 默认采用 `非严格模式` * * 若参数 `val` 为 number 类型, 并且是负整数 则返回 true, 否则返回 false * 若参数 `val` 为 string 类型, 并且通过验证为负整数字符串, 则返回 true, 否则返回 false * 若参数 `val` 不属于以上两种类型, 则直接返回 false * + * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + * * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false * - * e.g + * e.g. + * * 待校验参数 '-3' - * 若是严格模式, 则该参数值校验后, 返回 false - * 若是非严格模式, 则该参数值校验后, 返回 true + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true * * @param {*} val 待校验的参数 * @param {Object} options 可选参数 diff --git a/src/isNegativeNumber.js b/src/isNegativeNumber.js index 5d290a0..4ea6c2f 100644 --- a/src/isNegativeNumber.js +++ b/src/isNegativeNumber.js @@ -4,20 +4,25 @@ var _isObject = require('./isObject'); var REGEX_ENUM = require('./internal/enum/regexEnum'); /** - * 校验 `val` 是否为负数 + * 校验参数 `val` 是否为负数 * - * 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + * 该接口存在两种模式, 即严格模式、非严格模式; + * + * 默认采用`非严格模式` * * 若参数 `val` 为 number 类型, 并且是负数 则返回 true, 否则返回 false * 若参数 `val` 为 string 类型, 并且通过验证为负数字符串, 则返回 true, 否则返回 false * 若参数 `val` 不属于以上两种类型, 则直接返回 false * + * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + * * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false * - * e.g + * e.g. + * * 待校验参数 '-3' - * 若是严格模式, 则该参数值校验后, 返回 false - * 若是非严格模式, 则该参数值校验后, 返回 true + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true * * @param {*} val 待校验的参数 * @param {Object} options 可选参数 diff --git a/src/isNil.js b/src/isNil.js index 623f4ec..b25bca7 100644 --- a/src/isNil.js +++ b/src/isNil.js @@ -1,10 +1,9 @@ /** - * 校验 `val` 是否为 null 或 undefined + * 校验参数 `val` 是否为 null 或 undefined * - * 若是 - * 参数 `val` 的值恒等于 null, 则返回 true, - * 参数 `val` 的值恒等于 undefined, 则返回 true, + * 若参数 `val` 的值恒等于 null, 则返回 true, + * 若参数 `val` 的值恒等于 undefined, 则返回 true, * * 否则, 返回 false * @@ -14,7 +13,6 @@ * @since 0.0.1 */ function _isNil(val) { - // return val == null; return val === void 0 || val === null; } diff --git a/src/isNull.js b/src/isNull.js index fef70cb..6103e86 100644 --- a/src/isNull.js +++ b/src/isNull.js @@ -1,6 +1,6 @@ /** - * 校验 `val` 是否为 null + * 校验参数 `val` 是否为 null * * 若是参数 `val` 的值恒等于 null, 则返回 true, * diff --git a/src/isNumber.js b/src/isNumber.js index f17b91d..ca689aa 100644 --- a/src/isNumber.js +++ b/src/isNumber.js @@ -3,7 +3,7 @@ var DATA_TYPE_ENUM = require('./internal/enum/dataTypeEnum'); var assertDataType = require('./internal/assertDataType'); /** - * 校验 `val` 是否为 number + * 校验参数 `val` 是否为 number * * 若是参数 `val` 的类型为 `number` 或者 `[object Number]`时,返回 true, * diff --git a/src/isNumeric.js b/src/isNumeric.js index e0af8ff..257edfb 100644 --- a/src/isNumeric.js +++ b/src/isNumeric.js @@ -3,20 +3,25 @@ var _isRealNumber = require('./isRealNumber'); var _isInfinity = require('./isInfinity'); /** - * 校验 `val` 是否为数字 + * 校验参数 `val` 是否为数字 * - * 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + * 该接口存在两种模式, 即严格模式、非严格模式; + * + * 默认采用 `非严格模式` * * 若参数 `val` 为 number 类型, 并且不是 NaN, Infinity, -Infinity, 则返回 true, 否则返回 false * 若参数 `val` 为 string 类型, 并且可以经过 ToNumber 转换为非 NaN, Infinity, -Infinity 的数字, 则返回 true, 否则返回 false * 若参数 `val` 不属于以上两种类型, 则直接返回 false * + * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + * * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false * - * e.g + * e.g. + * * 待校验参数 '3' - * 若是严格模式, 则该参数值校验后, 返回 false - * 若是非严格模式, 则该参数值校验后, 返回 true + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true * * @param {*} val 待校验的参数 * @param {Object} options 可选参数 diff --git a/src/isObject.js b/src/isObject.js index 3ecb0a5..b20ddd0 100644 --- a/src/isObject.js +++ b/src/isObject.js @@ -3,9 +3,9 @@ var DATA_TYPE_ENUM = require('./internal/enum/dataTypeEnum'); var assertDataType = require('./internal/assertDataType'); /** - * 校验 `val` 是否为的 object + * 校验参数 `val` 是否为的 object * - * 若是参数 `val` 的类型为 `[object Object]` 时,返回 true, + * 若参数 `val` 的类型为 `[object Object]` 时,返回 true, * * 否则, 返回 false * diff --git a/src/isPhone.js b/src/isPhone.js index 9645f01..6d1f57d 100644 --- a/src/isPhone.js +++ b/src/isPhone.js @@ -3,7 +3,7 @@ var _isMobile = require('./isMobile'); var _isTelephone = require('./isTelephone'); /** - * 校验 `val` 是否为手机号码/座机号码 + * 校验参数 `val` 是否为手机号码/座机号码 * * 若参数 `val` 符合参数 `locale`(默认值: LOCALE_ENUM.ZHCN) 指定地区的号码格式, 则返回 true, 否则返回 false * diff --git a/src/isPlainObject.js b/src/isPlainObject.js index 22fec1b..88eb7ce 100644 --- a/src/isPlainObject.js +++ b/src/isPlainObject.js @@ -3,7 +3,7 @@ var _isObject = require('./isObject'); var _isFunction = require('./isFunction'); /** - * 校验 `val` 是否为纯粹的 object + * 校验参数 `val` 是否为纯粹的 object * * 若参数 `val` 是纯粹的 object, 则返回 true, 否则返回 false * diff --git a/src/isPositiveInteger.js b/src/isPositiveInteger.js index d64d648..1b8e74d 100644 --- a/src/isPositiveInteger.js +++ b/src/isPositiveInteger.js @@ -4,20 +4,25 @@ var _isObject = require('./isObject'); var REGEX_ENUM = require('./internal/enum/regexEnum'); /** - * 校验 `val` 是否为 正整数 + * 校验参数 `val` 是否为 正整数 * - * 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + * 该接口存在两种模式, 即严格模式、非严格模式; + * + * 默认采用 `非严格模式` * * 若参数 `val` 为 number 类型, 并且是正整数 则返回 true, 否则返回 false * 若参数 `val` 为 string 类型, 并且通过验证为正整数字符串, 则返回 true, 否则返回 false * 若参数 `val` 不属于以上两种类型, 则直接返回 false * + * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + * * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false * - * e.g + * e.g. + * * 待校验参数 '3' - * 若是严格模式, 则该参数值校验后, 返回 false - * 若是非严格模式, 则该参数值校验后, 返回 true + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true * * @param {*} val 待校验的参数 * @param {Object} options 可选参数 diff --git a/src/isPositiveNumber.js b/src/isPositiveNumber.js index e54ddff..7813582 100644 --- a/src/isPositiveNumber.js +++ b/src/isPositiveNumber.js @@ -4,20 +4,25 @@ var _isObject = require('./isObject'); var REGEX_ENUM = require('./internal/enum/regexEnum'); /** - * 校验 `val` 是否为 正数 + * 校验参数 `val` 是否为 正数 * - * 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + * 该接口存在两种模式, 即严格模式、非严格模式 + * + * 默认采用`非严格模式` * * 若参数 `val` 为 number 类型, 并且是正数 则返回 true, 否则返回 false * 若参数 `val` 为 string 类型, 并且通过验证为正数字符串, 则返回 true, 否则返回 false * 若参数 `val` 不属于以上两种类型, 则直接返回 false * + * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + * * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false * - * e.g + * e.g. + * * 待校验参数 '3' - * 若是严格模式, 则该参数值校验后, 返回 false - * 若是非严格模式, 则该参数值校验后, 返回 true + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true * * @param {*} val 待校验的参数 * @param {Object} options 可选参数 diff --git a/src/isRealNumber.js b/src/isRealNumber.js index 84f731d..52305fc 100644 --- a/src/isRealNumber.js +++ b/src/isRealNumber.js @@ -5,20 +5,25 @@ var _isObject = require('./isObject'); var _isUnEmptyString = require('./isUnEmptyString'); /** - * 校验 `val` 是否为实数(有理数和无理数) + * 校验参数 `val` 是否为实数(有理数和无理数) * - * 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + * 该接口存在两种模式, 即严格模式、非严格模式 + * + * 默认采用 `非严格模式` * * 若参数 `val` 为 number 类型, 并且不是 NaN, 则返回 true, 否则返回 false * 若参数 `val` 为 string 类型, 并且可以经过 ToNumber 转换为非 NaN 的数字, 则返回 true, 否则返回 false * 若参数 `val` 不属于以上两种类型, 则直接返回 false * + * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + * * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false * - * e.g + * e.g. + * * 待校验参数 '3' - * 若是严格模式, 则该参数值校验后, 返回 false - * 若是非严格模式, 则该参数值校验后, 返回 true + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true * * @param {*} val 待校验的参数 * @param {Object} options 可选参数 diff --git a/src/isString.js b/src/isString.js index 0ec19ce..25ebccd 100644 --- a/src/isString.js +++ b/src/isString.js @@ -3,7 +3,7 @@ var DATA_TYPE_ENUM = require('./internal/enum/dataTypeEnum'); var assertDataType = require('./internal/assertDataType'); /** - * 校验 `val` 是否为 string + * 校验参数 `val` 是否为 string * * 若参数 `val` 类型为 `string` 或者 `[object String]` 时,返回 true, * diff --git a/src/isTelephone.js b/src/isTelephone.js index d86115c..d16f401 100644 --- a/src/isTelephone.js +++ b/src/isTelephone.js @@ -4,7 +4,7 @@ var LOCALE_ENUM = require('./internal/enum/localeTypeEnum'); var REGEX_ENUM = require('./internal/enum/regexEnum'); /** - * 校验 `val` 是否为座机号码 + * 校验参数 `val` 是否为座机号码 * * 若参数 `val` 符合参数 `locale`(默认值: LOCALE_ENUM.ZHCN) 指定地区的座机号码格式, 则返回 true, 否则返回 false * diff --git a/src/isUnEmptyString.js b/src/isUnEmptyString.js index 35760d2..3325a93 100644 --- a/src/isUnEmptyString.js +++ b/src/isUnEmptyString.js @@ -3,9 +3,11 @@ var _isString = require('./isString'); var _isObject = require('./isObject'); /** - * 校验 `val` 是否为 非空字符串 + * 校验参数 `val` 是否为 非空字符串 * - * 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`严格模式` + * 该接口存在两种模式, 即严格模式、非严格模式; + * + * 默认采用 `严格模式` * * 若参数 `val` 不是 string, 则直接返回 false * 若参数 `val` 是 string, 并且不为空,则返回 true, 否则, 返回 false @@ -13,10 +15,11 @@ var _isObject = require('./isObject'); * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, * 则会对参数 `val` 进行两端去除空白(空字符),之后在校验其是否为非空字符串 * - * e.g + * e.g. + * * 待校验参数 ' ' - * 若是严格模式, 则该参数值校验后, 返回 false - * 若是非严格模式, 则该参数值校验后, 返回 true + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true * * @param {*} val 待校验的参数 * @param {Object} options 可选参数 diff --git a/src/isUnNegativeInteger.js b/src/isUnNegativeInteger.js index 0bc52c4..1483a8d 100644 --- a/src/isUnNegativeInteger.js +++ b/src/isUnNegativeInteger.js @@ -4,20 +4,25 @@ var _isObject = require('./isObject'); var REGEX_ENUM = require('./internal/enum/regexEnum'); /** - * 校验 `val` 是否为 非负整数, 即正整数和零 + * 校验参数 `val` 是否为 非负整数, 即正整数和零 * - * 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + * 该接口存在两种模式, 即严格模式、非严格模式; + * + * 默认采用 `非严格模式` * * 若参数 `val` 为 number 类型, 并且是非负整数 则返回 true, 否则返回 false * 若参数 `val` 为 string 类型, 并且通过验证为非负整数字符串, 则返回 true, 否则返回 false * 若参数 `val` 不属于以上两种类型, 则直接返回 false * + * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + * * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false * - * e.g + * e.g. + * * 待校验参数 '3' - * 若是严格模式, 则该参数值校验后, 返回 false - * 若是非严格模式, 则该参数值校验后, 返回 true + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true * * @param {*} val 待校验的参数 * @param {Object} options 可选参数 diff --git a/src/isUnNegativeNumber.js b/src/isUnNegativeNumber.js index 1126bb4..0fac399 100644 --- a/src/isUnNegativeNumber.js +++ b/src/isUnNegativeNumber.js @@ -4,20 +4,25 @@ var _isObject = require('./isObject'); var REGEX_ENUM = require('./internal/enum/regexEnum'); /** - * 校验 `val` 是否为非负数, 即正数和零 + * 校验参数 `val` 是否为非负数, 即正数和零 * - * 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + * 该接口存在两种模式, 即严格模式、非严格模式; + * + * 默认采用 `非严格模式` * * 若参数 `val` 为 number 类型, 并且是非负数 则返回 true, 否则返回 false * 若参数 `val` 为 string 类型, 并且通过验证为非负数字符串, 则返回 true, 否则返回 false * 若参数 `val` 不属于以上两种类型, 则直接返回 false * + * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + * * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false * - * e.g + * e.g. + * * 待校验参数 '3' - * 若是严格模式, 则该参数值校验后, 返回 false - * 若是非严格模式, 则该参数值校验后, 返回 true + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true * * @param {*} val 待校验的参数 * @param {Object} options 可选参数 diff --git a/src/isUnPositiveInteger.js b/src/isUnPositiveInteger.js index fb88fe7..f68e30b 100644 --- a/src/isUnPositiveInteger.js +++ b/src/isUnPositiveInteger.js @@ -4,20 +4,25 @@ var _isObject = require('./isObject'); var REGEX_ENUM = require('./internal/enum/regexEnum'); /** - * 校验 `val` 是否为 非正整数, 即负整数和零 + * 校验参数 `val` 是否为 非正整数, 即负整数和零 * - * 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + * 该接口存在两种模式, 即严格模式、非严格模式; + * + * 默认采用 `非严格模式` * * 若参数 `val` 为 number 类型, 并且是非正整数 则返回 true, 否则返回 false * 若参数 `val` 为 string 类型, 并且通过验证为非正整数字符串, 则返回 true, 否则返回 false * 若参数 `val` 不属于以上两种类型, 则直接返回 false * + * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + * * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false * - * e.g + * e.g. + * * 待校验参数 '-3' - * 若是严格模式, 则该参数值校验后, 返回 false - * 若是非严格模式, 则该参数值校验后, 返回 true + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true * * @param {*} val 待校验的参数 * @param {Object} options 可选参数 diff --git a/src/isUnPositiveNumber.js b/src/isUnPositiveNumber.js index 4b361fd..d7accf8 100644 --- a/src/isUnPositiveNumber.js +++ b/src/isUnPositiveNumber.js @@ -4,20 +4,25 @@ var _isObject = require('./isObject'); var REGEX_ENUM = require('./internal/enum/regexEnum'); /** - * 校验 `val` 是否为非正数, 即负数和零 + * 校验参数 `val` 是否为非正数, 即负数和零 * - * 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + * 该接口存在两种模式, 即严格模式、非严格模式; + * + * 默认采用 `非严格模式` * * 若参数 `val` 为 number 类型, 并且是非正数 则返回 true, 否则返回 false * 若参数 `val` 为 string 类型, 并且通过验证为非正数字符串, 则返回 true, 否则返回 false * 若参数 `val` 不属于以上两种类型, 则直接返回 false * + * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + * * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false * - * e.g + * e.g. + * * 待校验参数 '-3' - * 若是严格模式, 则该参数值校验后, 返回 false - * 若是非严格模式, 则该参数值校验后, 返回 true + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true * * @param {*} val 待校验的参数 * @param {Object} options 可选参数 diff --git a/src/isUnZero.js b/src/isUnZero.js index ebac68f..7eb26af 100644 --- a/src/isUnZero.js +++ b/src/isUnZero.js @@ -2,20 +2,25 @@ var _isNumeric = require('./isNumeric'); /** - * 校验 `val` 是否为 number, 并且不等于零 + * 校验参数 `val` 是否为 number, 并且不等于零 * - * 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + * 该接口存在两种模式, 即严格模式、非严格模式; + * + * 默认采用 `非严格模式` * * 若参数 `val` 为 number 类型, 并且不是 NaN, Infinity, -Infinity, 同时也不等于零, 则返回 true, 否则返回 false * 若参数 `val` 为 string 类型, 并且经过 ToNumber 转换为非 NaN, Infinity, -Infinity 的数字, 同时也不等于零, 则返回 true, 否则返回 false * 若参数 `val` 不属于以上两种类型, 则直接返回 false * + * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + * * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false * - * e.g + * e.g. + * * 待校验参数 '3' - * 若是严格模式, 则该参数值校验后, 返回 false - * 若是非严格模式, 则该参数值校验后, 返回 true + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true * * @param {*} val 待校验的参数 * @param {Object} options 可选参数 diff --git a/src/isUndefined.js b/src/isUndefined.js index dbeb08c..a205c84 100644 --- a/src/isUndefined.js +++ b/src/isUndefined.js @@ -1,6 +1,6 @@ /** - * 校验 `val` 是否为 undefined, + * 校验参数 `val` 是否为 undefined, * * 若是参数 `val` 的值恒等于 undefined, 则返回 true, * diff --git a/src/isZero.js b/src/isZero.js index fbe6170..51fe3e5 100644 --- a/src/isZero.js +++ b/src/isZero.js @@ -3,20 +3,25 @@ var _isObject = require('./isObject'); var _isRealNumber = require('./isRealNumber'); /** - * 校验 `val` 是否为零 + * 校验参数 `val` 是否为零 * - * 该接口存在两种模式, 即严格模式、非严格模式; 默认采用`非严格模式` + * 该接口存在两种模式, 即严格模式、非严格模式; + * + * 默认采用 `非严格模式` * * 若参数 `val` 为 number 类型, 并且等于零, 则返回 true, 否则返回 false * 若参数 `val` 为 string 类型, 并且经过 ToNumber 转换后的数据等于零, 则返回 true, 否则返回 false * 若参数 `val` 不属于以上两种类型, 则直接返回 false * + * 若参数 `val` 的值为空字符串(''、' '), 则直接返回 false + * * 若是参数 `options` 指定了严格模式, 即 options.isStrict = true, 则对于 string 类型直接返回 false * - * e.g + * e.g. + * * 待校验参数 '0' - * 若是严格模式, 则该参数值校验后, 返回 false - * 若是非严格模式, 则该参数值校验后, 返回 true + * > 若是严格模式, 则该参数值校验后, 返回 false + * > 若是非严格模式, 则该参数值校验后, 返回 true * * @param {*} val 待校验的参数 * @param {Object} options 可选参数 diff --git a/test/isEmail.test.js b/test/isEmail.test.js index bd78176..37999f7 100644 --- a/test/isEmail.test.js +++ b/test/isEmail.test.js @@ -37,4 +37,9 @@ describe('isEmail test', function() { it(`isEmail('dotx575099329@qingniu.co') === true`, function() { isEmail('dotx575099329@qingniu.co').should.equal(true); }); + + // 333 + it(`isEmail(333) === false`, function() { + isEmail(333).should.equal(false); + }); }); diff --git a/test/isEmptyString.test.js b/test/isEmptyString.test.js index bf7ac72..26c2218 100644 --- a/test/isEmptyString.test.js +++ b/test/isEmptyString.test.js @@ -8,6 +8,11 @@ should(); // Test describe('isEmptyString test', function() { + // 3 + it(`isEmptyString(3) === false`, function() { + isEmptyString(3).should.equal(false); + }); + // '3' it(`isEmptyString('3') === false`, function() { isEmptyString('3').should.equal(false); @@ -28,8 +33,23 @@ describe('isEmptyString test', function() { isEmptyString(' ').should.equal(true); }); - // '' + // ' ' it(`isEmptyString(' ', {isStrict: false}) === false`, function() { isEmptyString(' ', {isStrict: false}).should.equal(false); }); + + // null + it(`isEmptyString(null) === false`, function() { + isEmptyString(null).should.equal(false); + }); + + // undefined + it(`isEmptyString(undefined) === false`, function() { + isEmptyString(undefined).should.equal(false); + }); + + // NaN + it(`isEmptyString(NaN) === false`, function() { + isEmptyString(NaN).should.equal(false); + }); }); diff --git a/test/isInteger.test.js b/test/isInteger.test.js index aa394e6..6bab82c 100644 --- a/test/isInteger.test.js +++ b/test/isInteger.test.js @@ -18,14 +18,34 @@ describe('isInteger test', function() { isInteger('3').should.equal(true); }); - // 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.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); + }); + + // 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, {isStrict: true}) === true`, function() { + isInteger(0, {isStrict: true}).should.equal(true); + }); + + // '0' + it(`isInteger('0', {isStrict: true}) === false`, function() { + isInteger('0', {isStrict: true}).should.equal(false); }); // -3 @@ -38,19 +58,29 @@ describe('isInteger test', function() { isInteger('-3').should.equal(true); }); - // -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.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}) === false`, function() { - isInteger('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.3 + it(`isInteger(3.3, {isStrict: true}) === false`, function() { + isInteger(3.3, {isStrict: true}).should.equal(false); }); // '3.3' @@ -58,9 +88,19 @@ describe('isInteger test', 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.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.3' @@ -68,13 +108,48 @@ describe('isInteger test', function() { isInteger('-3.3', {isStrict: true}).should.equal(false); }); - // 0 - it(`isInteger(0) === true`, function() { - isInteger(0).should.equal(true); + // Number.POSITIVE_INFINITY + it(`isInteger(Number.POSITIVE_INFINITY) === false`, function() { + isInteger(Number.POSITIVE_INFINITY).should.equal(false); }); - // '0' - it(`isInteger('0') === true`, function() { - isInteger('0').should.equal(true); + // Number.POSITIVE_INFINITY + it(`isInteger(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function() { + isInteger(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + }); + + // '' + it(`isInteger('') === false`, function() { + isInteger('').should.equal(false); + }); + + // ' ' + it(`isInteger(' ') === false`, function() { + isInteger(' ').should.equal(false); + }); + + // null + it(`isInteger(null) === false`, function() { + isInteger(null).should.equal(false); + }); + + // undefined + it(`isInteger(undefined) === false`, function() { + isInteger(undefined).should.equal(false); + }); + + // NaN + it(`isInteger(NaN) === false`, function() { + isInteger(NaN).should.equal(false); + }); + + // Infinity + it(`isInteger(Infinity) === false`, function() { + isInteger(Number.POSITIVE_INFINITY).should.equal(false); + }); + + // -Infinity + it(`isInteger(-Infinity) === false`, function() { + isInteger(Number.NEGATIVE_INFINITY).should.equal(false); }); }); diff --git a/test/isJSON.test.js b/test/isJSON.test.js index 6189a34..5f7d9f8 100644 --- a/test/isJSON.test.js +++ b/test/isJSON.test.js @@ -13,6 +13,11 @@ describe('isJSON test', function() { isJSON('{"a": 3}').should.equal(true); }); + // {a: 3} + it(`isJSON('{a: 3}') === false`, function() { + isJSON('{a: 3}').should.equal(false); + }); + // '[3, 4]' it(`isJSON('[3, 4]') === false`, function() { isJSON('[3, 4]').should.equal(false); diff --git a/test/isMobile.test.js b/test/isMobile.test.js index c0d9e22..df77a9f 100644 --- a/test/isMobile.test.js +++ b/test/isMobile.test.js @@ -28,13 +28,23 @@ describe('isMobile test', function() { isMobile('1850550593').should.equal(false); }); - // '18505505933' + // '1850550 933' it(`isMobile('1850550 933') === false`, function() { isMobile('1850550 933').should.equal(false); }); - // '18505505933' + // '1850550-933' it(`isMobile('1850550-933') === false`, function() { isMobile('1850550-933').should.equal(false); }); + + // 18505505933 + it(`isMobile(18505505933) === false`, function() { + isMobile(18505505933).should.equal(false); + }); + + // '18505505933' + it(`isMobile('18505505933', 'en-US') === false`, function() { + isMobile('18505505933', 'en-US').should.equal(false); + }); }); diff --git a/test/isNegativeInteger.test.js b/test/isNegativeInteger.test.js index a6c02a3..19d2888 100644 --- a/test/isNegativeInteger.test.js +++ b/test/isNegativeInteger.test.js @@ -18,14 +18,34 @@ describe('isNegativeInteger test', 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.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); + }); + + // 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, {isStrict: true}) === false`, function() { + isNegativeInteger(0, {isStrict: true}).should.equal(false); + }); + + // '0' + it(`isNegativeInteger('0', {isStrict: true}) === false`, function() { + isNegativeInteger('0', {isStrict: true}).should.equal(false); }); // -3 @@ -38,19 +58,29 @@ describe('isNegativeInteger test', function() { isNegativeInteger('-3').should.equal(true); }); - // -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(true); }); - // '-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.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.3' @@ -58,9 +88,19 @@ describe('isNegativeInteger test', 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.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.3' @@ -68,13 +108,48 @@ describe('isNegativeInteger test', function() { isNegativeInteger('-3.3', {isStrict: true}).should.equal(false); }); - // 0 - it(`isNegativeInteger(0) === false`, function() { - isNegativeInteger(0).should.equal(false); + // Number.POSITIVE_INFINITY + it(`isNegativeInteger(Number.POSITIVE_INFINITY) === false`, function() { + isNegativeInteger(Number.POSITIVE_INFINITY).should.equal(false); }); - // '0' - it(`isNegativeInteger('0') === false`, function() { - isNegativeInteger('0').should.equal(false); + // Number.POSITIVE_INFINITY + it(`isNegativeInteger(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function() { + isNegativeInteger(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + }); + + // '' + it(`isNegativeInteger('') === false`, function() { + isNegativeInteger('').should.equal(false); + }); + + // ' ' + it(`isNegativeInteger(' ') === false`, function() { + isNegativeInteger(' ').should.equal(false); + }); + + // null + it(`isNegativeInteger(null) === false`, function() { + isNegativeInteger(null).should.equal(false); + }); + + // undefined + it(`isNegativeInteger(undefined) === false`, function() { + isNegativeInteger(undefined).should.equal(false); + }); + + // NaN + it(`isNegativeInteger(NaN) === false`, function() { + isNegativeInteger(NaN).should.equal(false); + }); + + // Infinity + it(`isNegativeInteger(Infinity) === false`, function() { + isNegativeInteger(Number.POSITIVE_INFINITY).should.equal(false); + }); + + // -Infinity + it(`isNegativeInteger(-Infinity) === false`, function() { + isNegativeInteger(Number.NEGATIVE_INFINITY).should.equal(false); }); }); diff --git a/test/isNegativeNumber.test.js b/test/isNegativeNumber.test.js index e2d0ce2..8d7a055 100644 --- a/test/isNegativeNumber.test.js +++ b/test/isNegativeNumber.test.js @@ -18,6 +18,11 @@ describe('isNegativeNumber test', function() { isNegativeNumber('-3').should.equal(true); }); + // -3 + it(`isNegativeNumber(-3, {isStrict: true}) === true`, function() { + isNegativeNumber(-3, {isStrict: true}).should.equal(true); + }); + // '-3' it(`isNegativeNumber('-3', {isStrict: true}) === false`, function() { isNegativeNumber('-3', {isStrict: true}).should.equal(false); @@ -33,6 +38,16 @@ describe('isNegativeNumber test', function() { isNegativeNumber('0').should.equal(false); }); + // 0 + it(`isNegativeNumber(0, {isStrict: true}) === false`, function() { + isNegativeNumber(0, {isStrict: true}).should.equal(false); + }); + + // '0' + it(`isNegativeNumber('0', {isStrict: true}) === false`, function() { + isNegativeNumber('0', {isStrict: true}).should.equal(false); + }); + // 3 it(`isNegativeNumber(3) === false`, function() { isNegativeNumber(3).should.equal(false); @@ -42,4 +57,59 @@ describe('isNegativeNumber test', function() { it(`isNegativeNumber('3') === false`, function() { isNegativeNumber('3').should.equal(false); }); + + // 3 + it(`isNegativeNumber(3, {isStrict: true}) === false`, function() { + isNegativeNumber(3, {isStrict: false}).should.equal(false); + }); + + // '3' + it(`isNegativeNumber('3', {isStrict: true}) === false`, 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); + }); + + // Number.POSITIVE_INFINITY + it(`isNegativeNumber(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function() { + isNegativeNumber(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + }); + + // '' + it(`isNegativeNumber('') === false`, function() { + isNegativeNumber('').should.equal(false); + }); + + // ' ' + it(`isNegativeNumber(' ') === false`, function() { + isNegativeNumber(' ').should.equal(false); + }); + + // null + it(`isNegativeNumber(null) === false`, function() { + isNegativeNumber(null).should.equal(false); + }); + + // undefined + it(`isNegativeNumber(undefined) === false`, function() { + isNegativeNumber(undefined).should.equal(false); + }); + + // NaN + it(`isNegativeNumber(NaN) === false`, function() { + isNegativeNumber(NaN).should.equal(false); + }); + + // Infinity + it(`isNegativeNumber(Infinity) === false`, function() { + isNegativeNumber(Number.POSITIVE_INFINITY).should.equal(false); + }); + + // -Infinity + it(`isNegativeNumber(-Infinity) === false`, function() { + isNegativeNumber(Number.NEGATIVE_INFINITY).should.equal(false); + }); }); diff --git a/test/isNumeric.test.js b/test/isNumeric.test.js index 57f882c..47cb534 100644 --- a/test/isNumeric.test.js +++ b/test/isNumeric.test.js @@ -18,6 +18,11 @@ describe('isNumeric test', function() { isNumeric('3').should.equal(true); }); + // 3 + it(`isNumeric(3, {isStrict: true}) === true`, function() { + isNumeric(3, {isStrict: true}).should.equal(true); + }); + // '3' it(`isNumeric('3', {isStrict: true}) === false`, function() { isNumeric('3', {isStrict: true}).should.equal(false); @@ -48,6 +53,11 @@ describe('isNumeric test', function() { isNumeric('').should.equal(false); }); + // ' ' + it(`isNumeric(' ') === false`, function() { + isNumeric(' ').should.equal(false); + }); + // null it(`isNumeric(null) === false`, function() { isNumeric(null).should.equal(false); diff --git a/test/isPositiveInteger.test.js b/test/isPositiveInteger.test.js index d2e10af..9026446 100644 --- a/test/isPositiveInteger.test.js +++ b/test/isPositiveInteger.test.js @@ -18,14 +18,34 @@ describe('isPositiveInteger test', function() { isPositiveInteger('3').should.equal(true); }); - // 3.3 - it(`isPositiveInteger(3.3) === false`, function() { - isPositiveInteger(3.3).should.equal(false); + // 3 + it(`isPositiveInteger(3, {isStrict: true}) === true`, function() { + isPositiveInteger(3, {isStrict: true}).should.equal(true); }); - // '3.3' - it(`isPositiveInteger('3.3') === false`, function() { - isPositiveInteger('3.3').should.to.be.equal(false); + // '3' + it(`isPositiveInteger('3', {isStrict: true}) === false`, function() { + isPositiveInteger('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, {isStrict: true}) === false`, function() { + isPositiveInteger(0, {isStrict: true}).should.equal(false); + }); + + // '0' + it(`isPositiveInteger('0', {isStrict: true}) === false`, function() { + isPositiveInteger('0', {isStrict: true}).should.equal(false); }); // -3 @@ -38,19 +58,29 @@ describe('isPositiveInteger test', 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.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 + it(`isPositiveInteger(3.3) === false`, function() { + isPositiveInteger(3.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, {isStrict: true}) === false`, function() { + isPositiveInteger(3.3, {isStrict: true}).should.equal(false); }); // '3.3' @@ -58,9 +88,19 @@ describe('isPositiveInteger test', 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.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.3 + it(`isPositiveInteger(-3.3, {isStrict: true}) === false`, function() { + isPositiveInteger(-3.3, {isStrict: true}).should.equal(false); }); // '-3.3' @@ -68,13 +108,48 @@ describe('isPositiveInteger test', function() { isPositiveInteger('-3.3', {isStrict: true}).should.equal(false); }); - // 0 - it(`isPositiveInteger(0) === false`, function() { - isPositiveInteger(0).should.equal(false); + // Number.POSITIVE_INFINITY + it(`isPositiveInteger(Number.POSITIVE_INFINITY) === false`, function() { + isPositiveInteger(Number.POSITIVE_INFINITY).should.equal(false); }); - // '0' - it(`isPositiveInteger('0') === false`, function() { - isPositiveInteger('0').should.equal(false); + // Number.POSITIVE_INFINITY + it(`isPositiveInteger(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function() { + isPositiveInteger(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + }); + + // '' + it(`isPositiveInteger('') === false`, function() { + isPositiveInteger('').should.equal(false); + }); + + // ' ' + it(`isPositiveInteger(' ') === false`, function() { + isPositiveInteger(' ').should.equal(false); + }); + + // null + it(`isPositiveInteger(null) === false`, function() { + isPositiveInteger(null).should.equal(false); + }); + + // undefined + it(`isPositiveInteger(undefined) === false`, function() { + isPositiveInteger(undefined).should.equal(false); + }); + + // NaN + it(`isPositiveInteger(NaN) === false`, function() { + isPositiveInteger(NaN).should.equal(false); + }); + + // Infinity + it(`isPositiveInteger(Infinity) === false`, function() { + isPositiveInteger(Number.POSITIVE_INFINITY).should.equal(false); + }); + + // -Infinity + it(`isPositiveInteger(-Infinity) === false`, function() { + isPositiveInteger(Number.NEGATIVE_INFINITY).should.equal(false); }); }); diff --git a/test/isPositiveNumber.test.js b/test/isPositiveNumber.test.js index dc12820..f3da27c 100644 --- a/test/isPositiveNumber.test.js +++ b/test/isPositiveNumber.test.js @@ -18,6 +18,11 @@ describe('isPositiveNumber test', function() { isPositiveNumber('3').should.equal(true); }); + // 3 + it(`isPositiveNumber(3, {isStrict: true}) === true`, function() { + isPositiveNumber(3, {isStrict: true}).should.equal(true); + }); + // '3' it(`isPositiveNumber('3', {isStrict: true}) === false`, function() { isPositiveNumber('3', {isStrict: true}).should.equal(false); @@ -33,6 +38,16 @@ describe('isPositiveNumber test', function() { isPositiveNumber('0').should.equal(false); }); + // 0 + it(`isPositiveNumber(0, {isStrict: true}) === false`, function() { + isPositiveNumber(0, {isStrict: true}).should.equal(false); + }); + + // '0' + it(`isPositiveNumber('0', {isStrict: true}) === false`, function() { + isPositiveNumber('0', {isStrict: true}).should.equal(false); + }); + // -3 it(`isPositiveNumber(-3) === false`, function() { isPositiveNumber(-3).should.equal(false); @@ -42,4 +57,59 @@ describe('isPositiveNumber test', function() { it(`isPositiveNumber('-3') === false`, function() { isPositiveNumber('-3').should.equal(false); }); + + // -3 + it(`isPositiveNumber(-3, {isStrict: true}) === false`, function() { + isPositiveNumber(-3, {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); + }); + + // Number.POSITIVE_INFINITY + it(`isPositiveNumber(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function() { + isPositiveNumber(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + }); + + // '' + it(`isPositiveNumber('') === false`, function() { + isPositiveNumber('').should.equal(false); + }); + + // ' ' + it(`isPositiveNumber(' ') === false`, function() { + isPositiveNumber(' ').should.equal(false); + }); + + // null + it(`isPositiveNumber(null) === false`, function() { + isPositiveNumber(null).should.equal(false); + }); + + // undefined + it(`isPositiveNumber(undefined) === false`, function() { + isPositiveNumber(undefined).should.equal(false); + }); + + // NaN + it(`isPositiveNumber(NaN) === false`, function() { + isPositiveNumber(NaN).should.equal(false); + }); + + // Infinity + it(`isPositiveNumber(Infinity) === false`, function() { + isPositiveNumber(Number.POSITIVE_INFINITY).should.equal(false); + }); + + // -Infinity + it(`isPositiveNumber(-Infinity) === false`, function() { + isPositiveNumber(Number.NEGATIVE_INFINITY).should.equal(false); + }); }); diff --git a/test/isRealNumber.test.js b/test/isRealNumber.test.js index aeb0fbf..a30891b 100644 --- a/test/isRealNumber.test.js +++ b/test/isRealNumber.test.js @@ -18,6 +18,11 @@ describe('isRealNumber test', function() { isRealNumber('3').should.equal(true); }); + // 3 + it(`isRealNumber(3, {isStrict: true}) === true`, function() { + isRealNumber(3, {isStrict: true}).should.equal(true); + }); + // '3' it(`isRealNumber('3', {isStrict: true}) === false`, function() { isRealNumber('3', {isStrict: true}).should.equal(false); @@ -48,6 +53,11 @@ describe('isRealNumber test', function() { isRealNumber('').should.equal(false); }); + // ' ' + it(`isRealNumber(' ') === false`, function() { + isRealNumber(' ').should.equal(false); + }); + // null it(`isRealNumber(null) === false`, function() { isRealNumber(null).should.equal(false); diff --git a/test/isTelephone.test.js b/test/isTelephone.test.js index 90db505..d68ab35 100644 --- a/test/isTelephone.test.js +++ b/test/isTelephone.test.js @@ -22,4 +22,14 @@ describe('isTelephone test', function() { it(`isTelephone('185055059334') === false`, function() { isTelephone('185055059334').should.equal(false); }); + + // 7632614 + it(`isTelephone(7632614) === false`, function() { + isTelephone(7632614).should.equal(false); + }); + + // '7632614' + it(`isTelephone('7632614', 'en-US') === false`, function() { + isTelephone('7632614', 'en-US').should.equal(false); + }); }); diff --git a/test/isUnEmptyString.test.js b/test/isUnEmptyString.test.js index 599515d..ef463e5 100644 --- a/test/isUnEmptyString.test.js +++ b/test/isUnEmptyString.test.js @@ -8,11 +8,21 @@ should(); // Test describe('isUnEmptyString test', function() { + // 3 + it(`isUnEmptyString(3) === false`, function() { + isUnEmptyString(3).should.equal(false); + }); + // '3' it(`isUnEmptyString('3') === true`, function() { isUnEmptyString('3').should.equal(true); }); + // 0 + it(`isUnEmptyString(0) === false`, function() { + isUnEmptyString(0).should.equal(false); + }); + // '' it(`isUnEmptyString('') === false`, function() { isUnEmptyString('').should.equal(false); @@ -28,8 +38,23 @@ describe('isUnEmptyString test', function() { isUnEmptyString(' ').should.equal(false); }); - // '' + // ' ' it(`isUnEmptyString(' ', {isStrict: false}) === true`, function() { isUnEmptyString(' ', {isStrict: false}).should.equal(true); }); + + // null + it(`isUnEmptyString(null) === false`, function() { + isUnEmptyString(null).should.equal(false); + }); + + // undefined + it(`isUnEmptyString(undefined) === false`, function() { + isUnEmptyString(undefined).should.equal(false); + }); + + // NaN + it(`isUnEmptyString(NaN) === false`, function() { + isUnEmptyString(NaN).should.equal(false); + }); }); diff --git a/test/isUnNegativeInteger.test.js b/test/isUnNegativeInteger.test.js index a2da386..c6a0468 100644 --- a/test/isUnNegativeInteger.test.js +++ b/test/isUnNegativeInteger.test.js @@ -18,14 +18,34 @@ describe('isUnNegativeInteger test', function() { isUnNegativeInteger('3').should.equal(true); }); - // 3.3 - it(`isUnNegativeInteger(3.3) === false`, function() { - isUnNegativeInteger(3.3).should.equal(false); + // 3 + it(`isUnNegativeInteger(3, {isStrict: true}) === true`, function() { + isUnNegativeInteger(3, {isStrict: true}).should.equal(true); }); - // '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); + }); + + // 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, {isStrict: true}) === true`, function() { + isUnNegativeInteger(0, {isStrict: true}).should.equal(true); + }); + + // '0' + it(`isUnNegativeInteger('0', {isStrict: true}) === false`, function() { + isUnNegativeInteger('0', {isStrict: true}).should.equal(false); }); // -3 @@ -38,19 +58,29 @@ describe('isUnNegativeInteger test', 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.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 + 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.3' @@ -58,9 +88,19 @@ describe('isUnNegativeInteger test', 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.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.3' @@ -68,13 +108,48 @@ describe('isUnNegativeInteger test', function() { isUnNegativeInteger('-3.3', {isStrict: true}).should.equal(false); }); - // 0 - it(`isUnNegativeInteger(0) === true`, function() { - isUnNegativeInteger(0).should.equal(true); + // Number.POSITIVE_INFINITY + it(`isUnNegativeInteger(Number.POSITIVE_INFINITY) === false`, function() { + isUnNegativeInteger(Number.POSITIVE_INFINITY).should.equal(false); }); - // '0' - it(`isUnNegativeInteger('0') === true`, function() { - isUnNegativeInteger('0').should.equal(true); + // Number.POSITIVE_INFINITY + it(`isUnNegativeInteger(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function() { + isUnNegativeInteger(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + }); + + // '' + it(`isUnNegativeInteger('') === false`, function() { + isUnNegativeInteger('').should.equal(false); + }); + + // ' ' + it(`isUnNegativeInteger(' ') === false`, function() { + isUnNegativeInteger(' ').should.equal(false); + }); + + // null + it(`isUnNegativeInteger(null) === false`, function() { + isUnNegativeInteger(null).should.equal(false); + }); + + // undefined + it(`isUnNegativeInteger(undefined) === false`, function() { + isUnNegativeInteger(undefined).should.equal(false); + }); + + // NaN + it(`isUnNegativeInteger(NaN) === false`, function() { + isUnNegativeInteger(NaN).should.equal(false); + }); + + // Infinity + it(`isUnNegativeInteger(Infinity) === false`, function() { + isUnNegativeInteger(Number.POSITIVE_INFINITY).should.equal(false); + }); + + // -Infinity + it(`isUnNegativeInteger(-Infinity) === false`, function() { + isUnNegativeInteger(Number.NEGATIVE_INFINITY).should.equal(false); }); }); diff --git a/test/isUnNegativeNumber.test.js b/test/isUnNegativeNumber.test.js index a620ba8..88d8a4e 100644 --- a/test/isUnNegativeNumber.test.js +++ b/test/isUnNegativeNumber.test.js @@ -18,6 +18,11 @@ describe('isUnNegativeNumber test', function() { isUnNegativeNumber('3').should.equal(true); }); + // 3 + it(`isUnNegativeNumber(3, {isStrict: true}) === true`, function() { + isUnNegativeNumber(3, {isStrict: true}).should.equal(true); + }); + // '3' it(`isUnNegativeNumber('3', {isStrict: true}) === false`, function() { isUnNegativeNumber('3', {isStrict: true}).should.equal(false); @@ -33,6 +38,16 @@ describe('isUnNegativeNumber test', function() { isUnNegativeNumber('0').should.equal(true); }); + // 0 + it(`isUnNegativeNumber(0, {isStrict: true}) === true`, function() { + isUnNegativeNumber(0, {isStrict: true}).should.equal(true); + }); + + // '0' + it(`isUnNegativeNumber('0', {isStrict: true}) === false`, function() { + isUnNegativeNumber('0', {isStrict: true}).should.equal(false); + }); + // -3 it(`isUnNegativeNumber(-3) === false`, function() { isUnNegativeNumber(-3).should.equal(false); @@ -42,4 +57,59 @@ describe('isUnNegativeNumber test', function() { it(`isUnNegativeNumber('-3') === false`, function() { isUnNegativeNumber('-3').should.equal(false); }); + + // -3 + it(`isUnNegativeNumber(-3, {isStrict: true}) === false`, function() { + isUnNegativeNumber(-3, {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); + }); + + // Number.POSITIVE_INFINITY + it(`isUnNegativeNumber(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function() { + isUnNegativeNumber(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + }); + + // '' + it(`isUnNegativeNumber('') === false`, function() { + isUnNegativeNumber('').should.equal(false); + }); + + // ' ' + it(`isUnNegativeNumber(' ') === false`, function() { + isUnNegativeNumber(' ').should.equal(false); + }); + + // null + it(`isUnNegativeNumber(null) === false`, function() { + isUnNegativeNumber(null).should.equal(false); + }); + + // undefined + it(`isUnNegativeNumber(undefined) === false`, function() { + isUnNegativeNumber(undefined).should.equal(false); + }); + + // NaN + it(`isUnNegativeNumber(NaN) === false`, function() { + isUnNegativeNumber(NaN).should.equal(false); + }); + + // Infinity + it(`isUnNegativeNumber(Infinity) === false`, function() { + isUnNegativeNumber(Number.POSITIVE_INFINITY).should.equal(false); + }); + + // -Infinity + it(`isUnNegativeNumber(-Infinity) === false`, function() { + isUnNegativeNumber(Number.NEGATIVE_INFINITY).should.equal(false); + }); }); diff --git a/test/isUnPositiveInteger.test.js b/test/isUnPositiveInteger.test.js index 47a1dc0..5b7aac6 100644 --- a/test/isUnPositiveInteger.test.js +++ b/test/isUnPositiveInteger.test.js @@ -18,14 +18,34 @@ describe('isUnPositiveInteger test', 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.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); + }); + + // 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, {isStrict: true}) === true`, function() { + isUnPositiveInteger(0, {isStrict: true}).should.equal(true); + }); + + // '0' + it(`isUnPositiveInteger('0', {isStrict: true}) === false`, function() { + isUnPositiveInteger('0', {isStrict: true}).should.equal(false); }); // -3 @@ -38,19 +58,29 @@ describe('isUnPositiveInteger test', function() { isUnPositiveInteger('-3').should.equal(true); }); - // -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.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.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.3' @@ -58,9 +88,19 @@ describe('isUnPositiveInteger test', 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.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.3' @@ -68,13 +108,48 @@ describe('isUnPositiveInteger test', function() { isUnPositiveInteger('-3.3', {isStrict: true}).should.equal(false); }); - // 0 - it(`isUnPositiveInteger(0) === true`, function() { - isUnPositiveInteger(0).should.equal(true); + // Number.POSITIVE_INFINITY + it(`isUnPositiveInteger(Number.POSITIVE_INFINITY) === false`, function() { + isUnPositiveInteger(Number.POSITIVE_INFINITY).should.equal(false); }); - // '0' - it(`isUnPositiveInteger('0') === true`, function() { - isUnPositiveInteger('0').should.equal(true); + // Number.POSITIVE_INFINITY + it(`isUnPositiveInteger(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function() { + isUnPositiveInteger(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + }); + + // '' + it(`isUnPositiveInteger('') === false`, function() { + isUnPositiveInteger('').should.equal(false); + }); + + // ' ' + it(`isUnPositiveInteger(' ') === false`, function() { + isUnPositiveInteger(' ').should.equal(false); + }); + + // null + it(`isUnPositiveInteger(null) === false`, function() { + isUnPositiveInteger(null).should.equal(false); + }); + + // undefined + it(`isUnPositiveInteger(undefined) === false`, function() { + isUnPositiveInteger(undefined).should.equal(false); + }); + + // NaN + it(`isUnPositiveInteger(NaN) === false`, function() { + isUnPositiveInteger(NaN).should.equal(false); + }); + + // Infinity + it(`isUnPositiveInteger(Infinity) === false`, function() { + isUnPositiveInteger(Number.POSITIVE_INFINITY).should.equal(false); + }); + + // -Infinity + it(`isUnPositiveInteger(-Infinity) === false`, function() { + isUnPositiveInteger(Number.NEGATIVE_INFINITY).should.equal(false); }); }); diff --git a/test/isUnPositiveNumber.test.js b/test/isUnPositiveNumber.test.js index 6356830..6bc625e 100644 --- a/test/isUnPositiveNumber.test.js +++ b/test/isUnPositiveNumber.test.js @@ -18,6 +18,11 @@ describe('isUnPositiveNumber test', function() { isUnPositiveNumber('-3').should.equal(true); }); + // -3 + it(`isUnPositiveNumber(-3, {isStrict: true}) === true`, function() { + isUnPositiveNumber(-3, {isStrict: true}).should.equal(true); + }); + // '-3' it(`isUnPositiveNumber('-3', {isStrict: true}) === false`, function() { isUnPositiveNumber('-3', {isStrict: true}).should.equal(false); @@ -33,6 +38,16 @@ describe('isUnPositiveNumber test', function() { isUnPositiveNumber('0').should.equal(true); }); + // 0 + it(`isUnPositiveNumber(0, {isStrict: true}) === true`, function() { + isUnPositiveNumber(0, {isStrict: true}).should.equal(true); + }); + + // '0' + it(`isUnPositiveNumber('0', {isStrict: true}) === false`, function() { + isUnPositiveNumber('0', {isStrict: true}).should.equal(false); + }); + // 3 it(`isUnPositiveNumber(3) === false`, function() { isUnPositiveNumber(3).should.equal(false); @@ -42,4 +57,59 @@ describe('isUnPositiveNumber test', function() { it(`isUnPositiveNumber('3') === false`, function() { isUnPositiveNumber('3').should.equal(false); }); + + // 3 + it(`isUnPositiveNumber(3, {isStrict: true}) === false`, function() { + isUnPositiveNumber(3, {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); + }); + + // Number.POSITIVE_INFINITY + it(`isUnPositiveNumber(Number.POSITIVE_INFINITY, {isStrict: true}) === false`, function() { + isUnPositiveNumber(Number.POSITIVE_INFINITY, {isStrict: true}).should.equal(false); + }); + + // '' + it(`isUnPositiveNumber('') === false`, function() { + isUnPositiveNumber('').should.equal(false); + }); + + // ' ' + it(`isUnPositiveNumber(' ') === false`, function() { + isUnPositiveNumber(' ').should.equal(false); + }); + + // null + it(`isUnPositiveNumber(null) === false`, function() { + isUnPositiveNumber(null).should.equal(false); + }); + + // undefined + it(`isUnPositiveNumber(undefined) === false`, function() { + isUnPositiveNumber(undefined).should.equal(false); + }); + + // NaN + it(`isUnPositiveNumber(NaN) === false`, function() { + isUnPositiveNumber(NaN).should.equal(false); + }); + + // Infinity + it(`isUnPositiveNumber(Infinity) === false`, function() { + isUnPositiveNumber(Number.POSITIVE_INFINITY).should.equal(false); + }); + + // -Infinity + it(`isUnPositiveNumber(-Infinity) === false`, function() { + isUnPositiveNumber(Number.NEGATIVE_INFINITY).should.equal(false); + }); }); diff --git a/test/isUnZero.test.js b/test/isUnZero.test.js index 3751b7f..010bfba 100644 --- a/test/isUnZero.test.js +++ b/test/isUnZero.test.js @@ -7,12 +7,17 @@ chai.use(require('chai-things')); should(); // Test -describe('isZero test', function() { +describe('isUnZero test', function() { // 3 it(`isUnZero(3) === true`, function() { isUnZero(3).should.equal(true); }); + // -3 + it(`isUnZero(-3) === true`, function() { + isUnZero(-3).should.equal(true); + }); + // '3' it(`isUnZero('3') === true`, function() { isUnZero('3').should.equal(true); @@ -55,6 +60,11 @@ describe('isZero test', function() { isUnZero('').should.equal(false); }); + // ' ' + it(`isUnZero(' ') === false`, function() { + isUnZero(' ').should.equal(false); + }); + // null it(`isUnZero(null) === false`, function() { isUnZero(null).should.equal(false); diff --git a/test/isZero.test.js b/test/isZero.test.js index f43d4f8..e7c5db4 100644 --- a/test/isZero.test.js +++ b/test/isZero.test.js @@ -13,6 +13,11 @@ describe('isZero test', function() { isZero(3).should.equal(false); }); + // -3 + it(`isZero(3) === false`, function() { + isZero(3).should.equal(false); + }); + it(`isZero(0) === true`, function() { isZero(0).should.equal(true); }); @@ -45,6 +50,11 @@ describe('isZero test', function() { isZero('').should.equal(false); }); + // ' ' + it(`isZero(' ') === false`, function() { + isZero(' ').should.equal(false); + }); + // null it(`isZero(null) === false`, function() { isZero(null).should.equal(false);