mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-15 06:39:33 +00:00
Add proper length constraint validations to all string mapped ORM fields, so they show a nice validation error, instead of a 500 error
Fixes issue #544
This commit is contained in:
parent
113e5b3bcd
commit
dc7c13479c
17 changed files with 43 additions and 0 deletions
|
|
@ -44,6 +44,7 @@ use App\Entity\Base\TimestampTrait;
|
|||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
|
||||
/**
|
||||
* This entity describes a part association, which is a semantic connection between two parts.
|
||||
|
|
@ -86,6 +87,7 @@ class PartAssociation extends AbstractDBElement implements TimeStampableInterfac
|
|||
#[Assert\Expression("this.getType().value !== 0 or this.getOtherType() !== null",
|
||||
message: 'validator.part_association.must_set_an_value_if_type_is_other')]
|
||||
#[Groups(['part_assoc:read', 'part_assoc:write'])]
|
||||
#[Length(max: 255)]
|
||||
protected ?string $other_type = null;
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue