Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(isLength): Fix linting and merge errors for #2019 #2474

Merged
merged 44 commits into from
Oct 16, 2024
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
ae711d6
Added Exact Condition for String Length & Updated README.md
bevatsal1122 Aug 6, 2022
f93cf70
Fixed Small Issue
bevatsal1122 Aug 6, 2022
cdd2192
Updated test/validators.js
bevatsal1122 Aug 6, 2022
27a40c8
Fixed in test/validators.js
bevatsal1122 Aug 6, 2022
cf729d1
Updated test/validators.js for isLength()
bevatsal1122 Aug 6, 2022
be706c4
Updated test/validators.js
bevatsal1122 Aug 6, 2022
db5b0c7
Updated test/validators.js
bevatsal1122 Aug 6, 2022
2e48053
Updated test/validators.js
bevatsal1122 Aug 6, 2022
c194526
Updated test/validators.js
bevatsal1122 Aug 6, 2022
21ec415
Updated test/validators.js
bevatsal1122 Aug 6, 2022
59abfc7
Fixed Small Issue
bevatsal1122 Aug 6, 2022
e1bb810
Fixed Small Issue
bevatsal1122 Aug 6, 2022
7c2c0cf
Fixed Small Issue
bevatsal1122 Aug 6, 2022
3ee58c0
Fixed Small Issue
bevatsal1122 Aug 6, 2022
d3e6ca5
Fixed Small Issue
bevatsal1122 Aug 6, 2022
b850b84
Fixed Small Issue
bevatsal1122 Aug 6, 2022
acfe071
Updated test/validators.js
bevatsal1122 Aug 6, 2022
cdb06a5
Updated test/validators.js
bevatsal1122 Aug 6, 2022
70775b4
Fixed Small Issue
bevatsal1122 Aug 6, 2022
a71b7ff
Renamed isPerfect to isValid
bevatsal1122 Aug 8, 2022
dc42e7f
Removed Backwards Compatibility for exact Feature
bevatsal1122 Aug 13, 2022
fb0def3
Fixed Minor Bug
bevatsal1122 Aug 13, 2022
ec1aa91
Fixed Small Issue
bevatsal1122 Aug 13, 2022
73dc505
Fixed Small Issue
bevatsal1122 Aug 13, 2022
c7605bc
Updated README.md, isLength.js & validators.js Files
bevatsal1122 Aug 13, 2022
93ac65f
Updated validators.js in test Folder
bevatsal1122 Aug 13, 2022
bc693dc
Included exact out of range Test
bevatsal1122 Aug 13, 2022
a90171f
Added Additional Test in validators.js for isLength
bevatsal1122 Aug 14, 2022
57a5633
Update src/lib/isLength.js
bevatsal1122 Nov 12, 2022
642e603
Update isLength.js
bevatsal1122 Nov 12, 2022
bb02daf
Updated discreteLengths only to be array
bevatsal1122 Nov 12, 2022
2a0a428
Resolved minor merged conflicts
bevatsal1122 Nov 12, 2022
1bf1ee4
Fixed minor bug
bevatsal1122 Nov 12, 2022
9fd65ed
Fixed minor bug
bevatsal1122 Nov 12, 2022
fd90691
Fixed tests for isLength
bevatsal1122 Nov 12, 2022
d09738c
Fixed minor bug
bevatsal1122 Nov 12, 2022
11aa19f
Minor test bug fixed
bevatsal1122 Nov 13, 2022
e63e7a5
Fixed minor bug in test/validator.js
bevatsal1122 Nov 13, 2022
3ef2588
Merge branch 'validatorjs:master' into MergeProposal
bevatsal1122 Nov 13, 2022
3b5cbd9
Update src/lib/isLength.js
bevatsal1122 Nov 18, 2022
2897ef9
Added blank lines between statements
bevatsal1122 Nov 18, 2022
22bb2f0
Updated isLength.js
bevatsal1122 Nov 18, 2022
bf34f6c
Merge remote-tracking branch 'origin/master' into 1937-support_exact_…
Suven-p Oct 11, 2024
f1cb604
Fix lint errors
Suven-p Oct 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added blank lines between statements
  • Loading branch information
bevatsal1122 committed Nov 18, 2022
commit 2897ef935bb15b24ed8fd6bb739f51c4828a696a
6 changes: 2 additions & 4 deletions src/lib/isLength.js
Original file line number Diff line number Diff line change
@@ -5,13 +5,15 @@ export default function isLength(str, options) {
assertString(str);
let min;
let max;

if (typeof (options) === 'object') {
min = options.min || 0;
max = options.max;
} else { // backwards compatibility: isLength(str, min [, max])
min = arguments[1] || 0;
max = arguments[2];
}

const presentationSequences = str.match(/(\uFE0F|\uFE0E)/g) || [];
const surrogatePairs = str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g) || [];
const len = str.length - presentationSequences.length - surrogatePairs.length;
@@ -21,9 +23,5 @@ export default function isLength(str, options) {
return options.discreteLengths.some(discreteLen => discreteLen === len);
}

return isInsideRange;
if (isInsideRange && Array.isArray(options?.discreteLengths)) {
return options.discreteLengths.some(discreteLen => discreteLen === len);
}
return isInsideRange;
}