Closed
Description
Symfony version(s) affected
6.4.3
Description
Doc says that we can pass false
to htmlPattern
parameter, but in reality this is not the case.
Setting htmlPattern to false will disable client side validation.
https://symfony.com/doc/6.4/reference/constraints/Regex.html#htmlpattern
Class:
How to reproduce
- Add assert constraint to an entity:
use Symfony\Component\Validator\Constraints as Assert;
// ...
#[Assert\Regex(
pattern: '/^[a-z]+(-[a-z]+)*$/',
htmlPattern: false,
)]
private ?string $slug = null;
- Run phpstan
- Error
------ ---------------------------------------------------------------------------------------------------------------------------------------
Line App/Entity/MyEntityphp
------ ---------------------------------------------------------------------------------------------------------------------------------------
33 Parameter $htmlPattern of attribute class Symfony\Component\Validator\Constraints\Regex constructor expects string|null, false given.
------ ---------------------------------------------------------------------------------------------------------------------------------------
Possible Solution
Allow boolean
or false
type on htmlPattern
parameter.
Additional Context
No response