由于Entities
更改了 fromMinLength
和MaxLength
to和to的断言Length
,验证器猜测者没有遵循这些更改并且属性没有被填充,因此 HTML 验证不适用于.Min
Max
Range
max_length
length
我认为应该有一个新的案例Symfony\Component\Validator\Constraints\Length
in guessMaxLengthForConstraint
function inSymfony\Component\Form\Extension\Validator\ValidatorTypeGuesser.php
还是已经解决了。
我正在使用 2.1.6 但我尝试了 2.1.7 并且没有区别我使用这个:
/**
* @var float $height
*
* @ORM\Column(name="height", type="decimal", nullable=true)
*
*
* @Assert\Range(
* min = "20",
* max = "96",
* minMessage = "You must be at least 20 tall",
* maxMessage = "You cannot taller than 96"
* )
* @Assert\NotBlank(groups={"registration_step_two","profile_measurement"})
* @Assert\Regex(pattern= "/[0-9]/",message="Require number only")
* @Assert\MinLength(10)
*/