-
Notifications
You must be signed in to change notification settings - Fork 187
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
alnum() misleading, should use ctype_alnum() #78
Comments
ctype is locale dependent, all our code does not depend on environment right now. |
Really? Got to do some research then. |
@webmozart See http://php.net/manual/en/function.ctype-alnum.php its reference to "default locale" and the link to |
I agree with @webmozart that this is confusing. I would expect that an alphanumeric check would mean that something like Maybe the check that it starts with a letter could be removed @beberlei? |
@mdavis1982 as far as I see, the problem is that this would break backwards compatibility of the library. You can find a very similar library where this and some other small issues are fixed here though: https://github.com/webmozart/assert |
@webmozart Of course. This could be fixed and tagged as a different version though? I'd like to contribute to the library to fix issues such as these (I'm going through all of the issues now). Do you think you could possibly contribute some of your other assertions to this library? |
@mdavis1982 That's what I tried, but @beberlei said he didn't want to make breaking changes. |
its not really a breaking change, because we are making the validation less strict. Making it stricter would be a problem though. I consider this a bug, if alnum actually means starting with 123 is allwoed as well. |
Hi, I'd like to draw your attention to this issue again since we're using the library a lot in our applications and find the nuance problematic when using alnum check from time to time. It says that "123" is not alphanumeric which, of course, is not true and is simply a bug. This forces us to write unnecessary regexes or manually use Any plans on fixing it soon? |
Hi. I'm happy to accept PRs on this. I'm sort of the de-facto maintainer now, but the library is still @beberlei's. As for BCs, I'm using semantic versioning (and nearly fully understanding it!!! Yay! Please excuse the hiccough in the V3.2 version .. should all be sorted now!), so a v4 and a clear differentiation would be nice, but things would really need to be tested as we don't all work in all environments. |
Also, as you are able to subclass the Assert library now, you may find it "simpler" to implement your own assertions on top of Assert. |
Currently, Assertion::alnum() tests that a value consists of alphabetic and numeric characters only and starts with a letter. I think this is misleading, as it is different to what ctype_alnum() does.
I think that alnum() should be changed to use ctype_alnum() internally, moreover helpers for the other ctype_*() functions should be implemented.
We can add another helper testing that a string starts with a letter:
startsWithLetter
(usingctype_alpha($string[0])
internally) - analogous tostartsWith
What do you think?
The text was updated successfully, but these errors were encountered: