You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The auto-validation introduced in #27735 leads to an Assert\Length() validator to doctrine mapped fields with a length, but breaks for fields with length and type binary because of an invalid charset.
How to reproduce
Create an entity with a field mapping including e.g.: @ORM\Column(type = "binary", length = 4). In the following, I call this field $hash.
Set the value of this field to a raw one, e.g. in the constructor $this->hash = \hash('crc32', 'whateverYouWantToHash\n...\nTest', true);
Create a form for this entity (no need for a field for the property $hash), you can have the form entirely for another field. Submit & validate the form. It will never be valid, as the Length validator will yield the invalid charset error for our $hash field.
Possible Solution
A workaround is to either:
simply disable the autovalidation (for this field)
overwrite the validation with an Assert\Length(groups={"notexisting"})
I feel like these are workarounds because I expect the validator to not only read and interpret part, but all of the doctrine annotation.
A possible solution would be to either:
interpret the whole doctrine annotation
make Assert\Length() charset independent (I do not know if and how this would be possible)
validate only the submitted fields instead of the whole entity
Additional context
The text was updated successfully, but these errors were encountered:
Symfony version(s) affected: 4.3.0, 4.3.1
Description
The auto-validation introduced in #27735 leads to an
Assert\Length()
validator to doctrine mapped fields with a length, but breaks for fields with length and typebinary
because of an invalid charset.How to reproduce
@ORM\Column(type = "binary", length = 4)
. In the following, I call this field$hash
.$this->hash = \hash('crc32', 'whateverYouWantToHash\n...\nTest', true);
$hash
), you can have the form entirely for another field. Submit & validate the form. It will never be valid, as the Length validator will yield the invalid charset error for our$hash
field.Possible Solution
A workaround is to either:
Assert\Length(groups={"notexisting"})
I feel like these are workarounds because I expect the validator to not only read and interpret part, but all of the doctrine annotation.
A possible solution would be to either:
Assert\Length()
charset independent (I do not know if and how this would be possible)Additional context
The text was updated successfully, but these errors were encountered: