Skip to content

Commit

Permalink
fix inefficient regular expressions on lowercase and uppercase rules
Browse files Browse the repository at this point in the history
  • Loading branch information
imbrn committed Jul 1, 2022
1 parent 472b06b commit 9239386
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/v8n.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,15 @@ const availableRules = {

pattern: expected => value => expected.test(value),

lowercase: () => value => /^([a-z]+\s*)+$/.test(value),
lowercase: () => value => {
return (
typeof value === 'boolean' ||
(value === value.toLowerCase() && value.trim() !== '')
);
},

uppercase: () => value => /^([A-Z]+\s*)+$/.test(value),
uppercase: () => value =>
value === value.toUpperCase() && value.trim() !== '',

vowel: () => value => /^[aeiou]+$/i.test(value),

Expand Down

0 comments on commit 9239386

Please sign in to comment.