-
-
Notifications
You must be signed in to change notification settings - Fork 917
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: allow banned as string #819
Conversation
Codecov Report
@@ Coverage Diff @@
## main #819 +/- ##
=======================================
Coverage 99.65% 99.65%
=======================================
Files 1988 1988
Lines 210192 210279 +87
Branches 904 909 +5
=======================================
+ Hits 209468 209555 +87
Misses 705 705
Partials 19 19
|
08095f0
to
4e42a65
Compare
54ec8aa
to
402b3dc
Compare
What would be the use case of providing a string instead of an array? This would allow me to provide an option like |
Yes exactly, it's the same as |
Ok, I think you misunderstood me. By providing a string at the bannedChars option I would expect the exact char pattern to be ignored. Even if the property has "*Chars" in the name. Example:
I'm sorry if this is confusing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails the following tests:
it('should be able to ban some characters via string', () => {
const actual = faker.random.alpha({
count: 5,
bannedChars: [
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
],
upcase: true,
});
expect(actual).toHaveLength(5);
expect(actual).toMatch(/^A{5}$/);
});
I know this isn't directly caused by this PR, but this PR explicitly lists uppercase characters as allowed (to be banned).
@ST-DDT You mean we need to add them to line 248 to 275? |
I would like have a |
okay, then this will be definitely another PR/issue |
I consider, this "fixed", if you remove the uppercase characters from the input (for now). I think we should do that as part of the |
Could you add a hint to the jsdocs regarding that behavior? |
a0b93d9
to
a62a43d
Compare
Await merge of #955 |
Ah yes, sorry! :) Indeed I requested this :) Then I think I had only this comment #819 (comment) which seems to be addressed? |
1b487e5
to
7b31e07
Compare
Following PRs need to be merged before this PR:
I would love to even type the non-array version, but sadly we still have not RegexTypes (microsoft/TypeScript#41160) in TS and we are limited (https://stackoverflow.com/questions/66294091/how-to-create-a-type-that-describes-string-with-only-digits)