Skip to content

Commit 3ae93a4

Browse files
author
Edward Xiao
committed
- Remove msg function condition: msg.func ? msg.func(nameText) : ' '
1 parent 241efc5 commit 3ae93a4

16 files changed

+85
-115
lines changed

lib/components/Checkbox.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,10 @@ function (_React$Component) {
221221
}
222222

223223
var _msg = _message.default[locale][TYPE];
224+
var nameText = name ? name : '';
224225

225226
if (!this.state.checked) {
226-
this.handleCheckEnd(true, _msg.unchecked ? _msg.unchecked(name ? name : '') : '');
227+
this.handleCheckEnd(true, _msg.unchecked(nameText));
227228
return;
228229
}
229230
}

lib/components/Radiobox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function (_React$Component) {
209209

210210
if (required) {
211211
if (isValidateValue(value)) {
212-
this.handleCheckEnd(true, msg.empty ? msg.empty(nameText) : '');
212+
this.handleCheckEnd(true, msg.empty(nameText));
213213
return;
214214
}
215215
}

lib/components/Select.js

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,9 @@ function (_React$Component) {
345345
if (this.currentFocus > -1) {
346346
if (x) {
347347
var node = x[this.currentFocus];
348+
/* istanbul ignore next */
348349

349-
if (node === null) {
350+
if (!node) {
350351
return;
351352
}
352353

@@ -356,11 +357,6 @@ function (_React$Component) {
356357
}
357358
} else {
358359
var _keycodeList = this.state.keycodeList;
359-
360-
if (!(keyCode >= 48 || keyCode <= 57 || keyCode >= 65 || keyCode <= 90 || keyCode >= 96 || keyCode <= 105)) {
361-
return;
362-
}
363-
364360
this.setTimeoutTyping();
365361

366362
var newkeyCodeList = _toConsumableArray(_keycodeList).concat([keyCode]);
@@ -418,6 +414,7 @@ function (_React$Component) {
418414

419415
var containerHeight = itemsWrapperNode.current.offsetHeight;
420416
var containerScrollTop = itemsWrapperNode.current.scrollTop;
417+
/* istanbul ignore next */
421418

422419
if (!this.currentFocus || !this.optionItems[this.currentFocus]) {
423420
return;
@@ -449,8 +446,6 @@ function (_React$Component) {
449446
}
450447
}
451448
}
452-
/* istanbul ignore next */
453-
454449

455450
if (direction === 'up') {
456451
this.corrected = false;
@@ -476,7 +471,7 @@ function (_React$Component) {
476471
var node = x[this.currentFocus];
477472
/* istanbul ignore next */
478473

479-
if (node === null) {
474+
if (!node) {
480475
return;
481476
}
482477

@@ -489,12 +484,6 @@ function (_React$Component) {
489484

490485
for (var i = 0; i < x.length; i += 1) {
491486
var node = x[i];
492-
/* istanbul ignore next */
493-
494-
if (node === null) {
495-
break;
496-
}
497-
498487
node.current.className = node.current.className.replace(reactInputsValidationCss['select__hover-active'], '');
499488
}
500489
}
@@ -504,9 +493,11 @@ function (_React$Component) {
504493
var node = this.wrapper;
505494
/* istanbul ignore next */
506495

507-
if (node === null) {
496+
if (!node) {
508497
return;
509498
}
499+
/* istanbul ignore next */
500+
510501

511502
if (node.current.contains(e.target)) {
512503
return;
@@ -560,7 +551,7 @@ function (_React$Component) {
560551

561552
if (required) {
562553
if (isValidateValue(value)) {
563-
this.handleCheckEnd(true, msg.empty ? msg.empty(nameText) : '');
554+
this.handleCheckEnd(true, msg.empty(nameText));
564555
return;
565556
}
566557
}

lib/components/Textarea.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ function (_React$Component) {
262262

263263
if (required) {
264264
if (_validator.default.empty(_value)) {
265-
this.handleCheckEnd(true, _msg.empty ? _msg.empty(nameText) : '');
265+
this.handleCheckEnd(true, _msg.empty(nameText));
266266
return;
267267
}
268268
}
@@ -271,7 +271,7 @@ function (_React$Component) {
271271
// CHECK REGEX
272272
if (reg) {
273273
if (_validator.default['reg'](reg, _value)) {
274-
this.handleCheckEnd(true, regMsg !== '' ? regMsg : _msg.invalid ? _msg.invalid(nameText) : '');
274+
this.handleCheckEnd(true, regMsg !== '' ? regMsg : _msg.invalid(nameText));
275275
return;
276276
}
277277
} // CHECK STRING
@@ -281,20 +281,20 @@ function (_React$Component) {
281281
if (min || max) {
282282
if (min && max) {
283283
if (String(_value).length < min || String(_value).length > max) {
284-
this.handleCheckEnd(true, _msg.inBetween ? _msg.inBetween(nameText)(min)(max) : '');
284+
this.handleCheckEnd(true, _msg.inBetween(nameText)(min)(max));
285285
return;
286286
}
287287
} else {
288288
if (min) {
289289
if (String(_value).length < min) {
290-
this.handleCheckEnd(true, _msg.lessThan ? _msg.lessThan(nameText)(min) : '');
290+
this.handleCheckEnd(true, _msg.lessThan(nameText)(min));
291291
return;
292292
}
293293
}
294294

295295
if (max) {
296296
if (String(_value).length > max) {
297-
this.handleCheckEnd(true, _msg.greaterThan ? _msg.greaterThan(nameText)(max) : '');
297+
this.handleCheckEnd(true, _msg.greaterThan(nameText)(max));
298298
return;
299299
}
300300
}
@@ -303,7 +303,7 @@ function (_React$Component) {
303303

304304
if (length) {
305305
if (String(_value).length !== length) {
306-
this.handleCheckEnd(true, _msg.lengthEqual ? _msg.lengthEqual(nameText)(length) : '');
306+
this.handleCheckEnd(true, _msg.lengthEqual(nameText)(length));
307307
return;
308308
}
309309
}

lib/components/Textbox.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ function (_React$Component) {
285285

286286
if (required) {
287287
if (_validator.default.empty(_value)) {
288-
this.handleCheckEnd(true, _msg.empty ? _msg.empty(nameText) : '');
288+
this.handleCheckEnd(true, _msg.empty(nameText));
289289
return;
290290
}
291291
}
@@ -294,7 +294,7 @@ function (_React$Component) {
294294
// CHECK REGEX
295295
if (reg) {
296296
if (_validator.default['reg'](reg, _value)) {
297-
this.handleCheckEnd(true, regMsg !== '' ? regMsg : _msg.invalid ? _msg.invalid(nameText) : '');
297+
this.handleCheckEnd(true, regMsg !== '' ? regMsg : _msg.invalid(nameText));
298298
return;
299299
}
300300
} // CHECK STRING
@@ -304,20 +304,20 @@ function (_React$Component) {
304304
if (min || max) {
305305
if (min && max) {
306306
if (String(_value).length < min || String(_value).length > max) {
307-
this.handleCheckEnd(true, _msg.inBetween ? _msg.inBetween(nameText)(min)(max) : '');
307+
this.handleCheckEnd(true, _msg.inBetween(nameText)(min)(max));
308308
return;
309309
}
310310
} else {
311311
if (min) {
312312
if (String(_value).length < min) {
313-
this.handleCheckEnd(true, _msg.lessThan ? _msg.lessThan(nameText)(min) : '');
313+
this.handleCheckEnd(true, _msg.lessThan(nameText)(min));
314314
return;
315315
}
316316
}
317317

318318
if (max) {
319319
if (String(_value).length > max) {
320-
this.handleCheckEnd(true, _msg.greaterThan ? _msg.greaterThan(nameText)(max) : '');
320+
this.handleCheckEnd(true, _msg.greaterThan(nameText)(max));
321321
return;
322322
}
323323
}
@@ -326,7 +326,7 @@ function (_React$Component) {
326326

327327
if (length) {
328328
if (String(_value).length !== length) {
329-
this.handleCheckEnd(true, _msg.lengthEqual ? _msg.lengthEqual(nameText)(length) : '');
329+
this.handleCheckEnd(true, _msg.lengthEqual(nameText)(length));
330330
return;
331331
}
332332
}
@@ -335,27 +335,27 @@ function (_React$Component) {
335335

336336
if (type === VALIDATE_OPTION_TYPE_LIST[1]) {
337337
if (!_validator.default[type](_value)) {
338-
this.handleCheckEnd(true, _msg.invalid ? _msg.invalid(nameText) : '');
338+
this.handleCheckEnd(true, _msg.invalid(nameText));
339339
return;
340340
}
341341

342342
if (min || max) {
343343
if (min && max) {
344344
if (!_validator.default[type](_value, min, max)) {
345-
this.handleCheckEnd(true, _msg.inBetween ? _msg.inBetween(nameText)(min)(max) : '');
345+
this.handleCheckEnd(true, _msg.inBetween(nameText)(min)(max));
346346
return;
347347
}
348348
} else {
349349
if (min) {
350350
if (!_validator.default[type](_value, min)) {
351-
this.handleCheckEnd(true, _msg.lessThan ? _msg.lessThan(nameText)(min) : '');
351+
this.handleCheckEnd(true, _msg.lessThan(nameText)(min));
352352
return;
353353
}
354354
}
355355

356356
if (max) {
357357
if (!_validator.default[type](_value, 0, max)) {
358-
this.handleCheckEnd(true, _msg.greaterThan ? _msg.greaterThan(nameText)(max) : '');
358+
this.handleCheckEnd(true, _msg.greaterThan(nameText)(max));
359359
return;
360360
}
361361
}
@@ -364,7 +364,7 @@ function (_React$Component) {
364364

365365
if (length) {
366366
if (String(_value).length !== length) {
367-
this.handleCheckEnd(true, _msg.lengthEqual ? _msg.lengthEqual(nameText)(length) : '');
367+
this.handleCheckEnd(true, _msg.lengthEqual(nameText)(length));
368368
return;
369369
}
370370
}
@@ -373,7 +373,7 @@ function (_React$Component) {
373373

374374
if (compare && compare !== '') {
375375
if (_value !== compare) {
376-
this.handleCheckEnd(true, _msg.twoInputsNotEqual ? _msg.twoInputsNotEqual() : '');
376+
this.handleCheckEnd(true, _msg.twoInputsNotEqual());
377377
return;
378378
}
379379
}

lib/react-inputs-validation.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-inputs-validation.js.map

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

lib/react-inputs-validation.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-inputs-validation.min.js.map

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-inputs-validation",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"description": "a react inputs validation component",
55
"main": "index.js",
66
"repository": {
@@ -13,7 +13,7 @@
1313
"bugs": {
1414
"url": "https://github.com/edwardfhsiao/react-inputs-validation/issues"
1515
},
16-
"homepage": "https://github.com/edwardfhsiao/react-inputs-validation#readme",
16+
"homepage": "https://edwardfhsiao.github.io/react-inputs-validation",
1717
"scripts": {
1818
"test": "NODE_ENV=test jest",
1919
"test:coverage": "npm run tslint && npm run jslint && npm test -- --coverage",

0 commit comments

Comments
 (0)