-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: get feedback from translations * feat: add translations * chore: update readme * refactor: change patterns names * chore: update README * chore: update README * tests: update test matcher strings * fix: update translations + suggestions * tests: add translations assertions * fix: minor bug fix * fix: minor bug fix * chore: update readme * chore: update readme * fix: update matcher suggestions * fix: add v4 beta as peer dependenvy * chore: update readme regarding version * fix: add translated suggestions to matchers * tests: refactor tests to go through the zxcvbn-ts/core package * tests: add suggestions assertions * tests: remove redundant lines * feat: add max length matcher * tests: max length unit tests --------- Co-authored-by: Ilan Kushnir <[email protected]>
- Loading branch information
1 parent
69e1b95
commit 777fb3d
Showing
5 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Matcher, Match } from '@zxcvbn-ts/core'; | ||
|
||
export const maxLengthMatcher = (maxLength: number): Matcher => ({ | ||
Matching: class MaxLengthMatcher { | ||
match({ password }: { password: string }): Match[] { | ||
const matches: Match[] = []; | ||
if (password.length > maxLength) { | ||
matches.push({ pattern: 'maxLength', token: password, i: 0, j: password.length - 1 }); | ||
} | ||
return matches; | ||
} | ||
}, | ||
feedback: options => { | ||
return { | ||
warning: options.translations.warnings['maxLength']?.replace('%s', maxLength) || 'maxLength', | ||
suggestions: [options.translations.suggestions['maxLength']?.replace('%s', maxLength) || 'maxLength'], | ||
}; | ||
}, | ||
scoring() { | ||
return -100; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters