Skip to content

Commit e33d38a

Browse files
committed
Rename isNull to isEmpty, re #574
1 parent 88bef4a commit e33d38a

File tree

9 files changed

+16
-14
lines changed

9 files changed

+16
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#### HEAD
22

3+
- Renamed `isNull()` to `isEmpty()`
4+
([#574](https://github.com/chriso/validator.js/issues/574))
35
- Improved `normalizeEmail()`
46
([#583](https://github.com/chriso/validator.js/pull/583))
57

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Passing anything other than a string is an error.
6969
- **isDecimal(str)** - check if the string represents a decimal number, such as 0.1, .3, 1.1, 1.00003, 4.0, etc.
7070
- **isDivisibleBy(str, number)** - check if the string is a number that's divisible by another.
7171
- **isEmail(str [, options])** - check if the string is an email. `options` is an object which defaults to `{ allow_display_name: false, allow_utf8_local_part: true, require_tld: true }`. If `allow_display_name` is set to true, the validator will also match `Display Name <email-address>`. If `allow_utf8_local_part` is set to false, the validator will not allow any non-English UTF8 character in email address' local part. If `require_tld` is set to false, e-mail addresses without having TLD in their domain will also be matched.
72+
- **isEmpty(str)** - check if the string has a length of zero.
7273
- **isFQDN(str [, options])** - check if the string is a fully qualified domain name (e.g. domain.com). `options` is an object which defaults to `{ require_tld: true, allow_underscores: false, allow_trailing_dot: false }`.
7374
- **isFloat(str [, options])** - check if the string is a float. `options` is an object which can contain the keys `min` and/or `max` to validate the float is within boundaries (e.g. `{ min: 7.22, max: 9.55 }`).
7475
- **isFullWidth(str)** - check if the string contains any full-width chars.
@@ -89,7 +90,6 @@ Passing anything other than a string is an error.
8990
- **isMobilePhone(str, locale)** - check if the string is a mobile phone number, (locale is one of `['ar-DZ', 'ar-SA', 'ar-SY', 'cs-CZ', 'de-DE', 'da-DK', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-CA', 'en-ZA', 'en-ZM', 'es-ES', 'fi-FI', 'fr-FR', 'hu-HU', 'it-IT', 'ja-JP', 'ms-MY', 'nb-NO', 'nn-NO', 'pl-PL', 'pt-PT', 'ru-RU', 'sr-RS', 'tr-TR', 'vi-VN', 'zh-CN', 'zh-TW']`).
9091
- **isMongoId(str)** - check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid].
9192
- **isMultibyte(str)** - check if the string contains one or more multibyte chars.
92-
- **isNull(str)** - check if the string is null (has a length of zero).
9393
- **isNumeric(str)** - check if the string contains only numbers.
9494
- **isSurrogatePair(str)** - check if the string contains any surrogate pairs chars.
9595
- **isURL(str [, options])** - check if the string is an URL. `options` is an object which defaults to `{ protocols: ['http','https','ftp'], require_tld: true, require_protocol: false, require_host: true, require_valid_protocol: true, allow_underscores: false, host_whitelist: false, host_blacklist: false, allow_trailing_dot: false, allow_protocol_relative_urls: false }`.

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ var _isJSON = require('./lib/isJSON');
132132

133133
var _isJSON2 = _interopRequireDefault(_isJSON);
134134

135-
var _isNull = require('./lib/isNull');
135+
var _isEmpty = require('./lib/isEmpty');
136136

137-
var _isNull2 = _interopRequireDefault(_isNull);
137+
var _isEmpty2 = _interopRequireDefault(_isEmpty);
138138

139139
var _isLength = require('./lib/isLength');
140140

@@ -263,7 +263,7 @@ var validator = {
263263
isHexColor: _isHexColor2.default,
264264
isMD5: _isMD2.default,
265265
isJSON: _isJSON2.default,
266-
isNull: _isNull2.default,
266+
isEmpty: _isEmpty2.default,
267267
isLength: _isLength2.default, isByteLength: _isByteLength2.default,
268268
isUUID: _isUUID2.default, isMongoId: _isMongoId2.default,
269269
isDate: _isDate2.default, isAfter: _isAfter2.default, isBefore: _isBefore2.default,

lib/isNull.js renamed to lib/isEmpty.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
6-
exports.default = isNull;
6+
exports.default = isEmpty;
77

88
var _assertString = require('./util/assertString');
99

1010
var _assertString2 = _interopRequireDefault(_assertString);
1111

1212
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1313

14-
function isNull(str) {
14+
function isEmpty(str) {
1515
(0, _assertString2.default)(str);
1616
return str.length === 0;
1717
}

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import isHexColor from './lib/isHexColor';
4040
import isMD5 from './lib/isMD5';
4141

4242
import isJSON from './lib/isJSON';
43-
import isNull from './lib/isNull';
43+
import isEmpty from './lib/isEmpty';
4444

4545
import isLength from './lib/isLength';
4646
import isByteLength from './lib/isByteLength';
@@ -97,7 +97,7 @@ const validator = {
9797
isHexColor,
9898
isMD5,
9999
isJSON,
100-
isNull,
100+
isEmpty,
101101
isLength, isByteLength,
102102
isUUID, isMongoId,
103103
isDate, isAfter, isBefore,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assertString from './util/assertString';
22

3-
export default function isNull(str) {
3+
export default function isEmpty(str) {
44
assertString(str);
55
return str.length === 0;
66
}

test/validators.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ describe('Validators', function () {
12511251

12521252
it('should validate null strings', function () {
12531253
test({
1254-
validator: 'isNull',
1254+
validator: 'isEmpty',
12551255
valid: [
12561256
'',
12571257
],
@@ -3395,7 +3395,7 @@ describe('Validators', function () {
33953395
it('should error on non-string input', function () {
33963396
var empty = [undefined, null, [], NaN];
33973397
empty.forEach(function (item) {
3398-
assert.throws(validator.isNull.bind(null, item));
3398+
assert.throws(validator.isEmpty.bind(null, item));
33993399
});
34003400
});
34013401

validator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@
626626
return false;
627627
}
628628

629-
function isNull(str) {
629+
function isEmpty(str) {
630630
assertString(str);
631631
return str.length === 0;
632632
}
@@ -1246,7 +1246,7 @@
12461246
isHexColor: isHexColor,
12471247
isMD5: isMD5,
12481248
isJSON: isJSON,
1249-
isNull: isNull,
1249+
isEmpty: isEmpty,
12501250
isLength: isLength, isByteLength: isByteLength,
12511251
isUUID: isUUID, isMongoId: isMongoId,
12521252
isDate: isDate, isAfter: isAfter, isBefore: isBefore,

validator.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)