-
-
Save hesco/0dc7290a83f845657e83 to your computer and use it in GitHub Desktop.
Mojolicious::Validator->like() question:
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
Why does this work: | |
$validation->required('instructors.fname')->size(1,35); | |
But this does not: | |
$validation->required('instructors.fname')->size(1,35)->like(qr/^[\w]$/); | |
My test is a count(*) on one of the effected tables. | |
With the former validation test in place, the count increments. | |
Roll the latter version into place and restart the app, | |
and the count does not increment. | |
What am I missing here please? | |
This: | |
->like(qr/^[\w]$/) | |
fails in unexpected ways (ways in which I think the check should pass), | |
although these: | |
->like($RE{Email}{Address}), | |
->like(Number::Phone::US::get_regex(), and | |
->like($RE{zip}{US}) | |
all seem to work just fine. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/^[\w]$ only matches a single character - is that what you want?
Also it's an unnecessary use of a character class ([ ... ])
I think you mean this: /^\w+$