Reputation: 1253
I have a form field that I want to match the following rules: at least 3 numbers then at least 7 a-z or A-Z letters, currently I have this but it does not work apparently because I get that my input is not valid even if I respect the rule I mentioned :
->add('NumberAcc', TextType::class, [
'constraints' => [
new NotBlank(),
new Regex('/[0-9]{3,},[a-z]{7,}/')
],
])
Any ideas? (I know it wont work with Maj letters right now but it doesn't work either with lowercase letters
Upvotes: 2
Views: 10772
Reputation: 13394
Your regex contains a comma ,
between the numbers and the letters, which is not in the description of what you are trying to do. Also, if you want to capture both a-z
and A-Z
you have to explicitly specify it
/[0-9]{3,}[a-zA-Z]{7,}/
or make the regex case insensitive
/[0-9]{3,}[a-z]{7,}/i
Upvotes: 5