-
-
Notifications
You must be signed in to change notification settings - Fork 943
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
. is not working in faker.helpers.fromRegExp #3302
Comments
I noticed that as well. Thanks for creating all these issues for those bugs. |
It appears this has never worked The snapshot tests have looked like this since the feature was added in #1569 https://github.com/faker-js/faker/blame/next/test/modules/__snapshots__/helpers.spec.ts.snap
|
I'd suggest just removing the ". => returns a wildcard ASCII character that can be any number, character or symbol. Can be combined with quantifiers as well." from the docs, as well as that example and the snapshot tests |
This is supposed to be regex. |
Unfortunately, there are more issues with the current implementation, that aren't easily fixable.
We might have to replace the entire (?) implementation |
I don't think it's such a big deal if We should bear in mind RegExps are typically used to match a pattern. We are using them "backwards" - ie, generating a string which would match a given regexp. We'll likely only ever be able to support a subset of Regexp features, because Regexp is pretty complicated. Although not matching a . wildcard would be a serious problem in a matching library, it doesn't seem that bad in this reversed generation scenario, because it's fairly rare to need a fake pattern which genuinely allows ANY character in a position. More commonly you'd need some subset like a-z, A-Z, 0-9, and some specific punctuation, and in that case it would be better to explicitly list them out. It wouldn't be very obvious what characters . might generate (is space allowed? è? ~? ฒ? 🕺🏽?) |
One of the examples in faker.helpers.fromRegexp is
faker.helpers.fromRegExp(/.{5}/) // '14(#B'
However this actually always returns '.....'
It's supposed to work like:
. => returns a wildcard ASCII character that can be any number, character or symbol. Can be combined with quantifiers as well.
found while testing #3301
The text was updated successfully, but these errors were encountered: