mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-14 06:09: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
|
|
@ -28,6 +28,7 @@ use App\Entity\Parts\Part;
|
|||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
|
||||
/**
|
||||
* Advanced properties of a part, not related to a more specific group.
|
||||
|
|
@ -62,6 +63,7 @@ trait AdvancedPropertyTrait
|
|||
#[Assert\Length(max: 100)]
|
||||
#[Groups(['extended', 'full', 'import', 'part:read', 'part:write'])]
|
||||
#[ORM\Column(type: Types::STRING, length: 100, unique: true, nullable: true)]
|
||||
#[Length(max: 100)]
|
||||
protected ?string $ipn = null;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ use App\Validator\Constraints\Selectable;
|
|||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
|
||||
/**
|
||||
* In this trait all manufacturer related properties of a part are collected (like MPN, manufacturer URL).
|
||||
|
|
@ -58,6 +59,7 @@ trait ManufacturerTrait
|
|||
*/
|
||||
#[Groups(['extended', 'full', 'import', 'part:read', 'part:write'])]
|
||||
#[ORM\Column(type: Types::STRING)]
|
||||
#[Length(max: 255)]
|
||||
protected string $manufacturer_product_number = '';
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue