Skip to content

Commit 8bc807f

Browse files
committed
#6113: Validate range-words in Form component (UI Component)
- Changed range-words validation logic
1 parent 465e14b commit 8bc807f

File tree

1 file changed

+4
-2
lines changed
  • app/code/Magento/Ui/view/base/web/js/lib/validation

1 file changed

+4
-2
lines changed

app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ define([
8484
],
8585
'range-words': [
8686
function (value, params) {
87-
return utils.stripHtml(value).match(/\b\w+\b/g).length >= params[0] &&
88-
utils.stripHtml(value).match(/\b\w+\b/g).length < params[1];
87+
var match = utils.stripHtml(value).match(/\b\w+\b/g) || [];
88+
89+
return match.length >= params[0] &&
90+
match.length <= params[1];
8991
},
9092
$.mage.__('Please enter between {0} and {1} words.')
9193
],

0 commit comments

Comments
 (0)