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:
Jan Böhmer 2024-03-06 19:46:11 +01:00
parent 113e5b3bcd
commit dc7c13479c
17 changed files with 43 additions and 0 deletions

View file

@ -50,6 +50,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
*/
#[Groups(['full', 'company:read', 'company:write'])]
#[ORM\Column(type: Types::STRING)]
#[Assert\Length(max: 255)]
protected string $address = '';
/**
@ -57,6 +58,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
*/
#[Groups(['full', 'company:read', 'company:write'])]
#[ORM\Column(type: Types::STRING)]
#[Assert\Length(max: 255)]
protected string $phone_number = '';
/**
@ -64,6 +66,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
*/
#[Groups(['full', 'company:read', 'company:write'])]
#[ORM\Column(type: Types::STRING)]
#[Assert\Length(max: 255)]
protected string $fax_number = '';
/**
@ -72,6 +75,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
#[Assert\Email]
#[Groups(['full', 'company:read', 'company:write'])]
#[ORM\Column(type: Types::STRING)]
#[Assert\Length(max: 255)]
protected string $email_address = '';
/**
@ -80,6 +84,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
#[Assert\Url]
#[Groups(['full', 'company:read', 'company:write'])]
#[ORM\Column(type: Types::STRING)]
#[Assert\Length(max: 255)]
protected string $website = '';
#[Groups(['company:read', 'company:write'])]
@ -89,6 +94,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
* @var string The link to the website of an article. Use %PARTNUMBER% as placeholder for the part number.
*/
#[ORM\Column(type: Types::STRING)]
#[Assert\Length(max: 255)]
protected string $auto_product_url = '';
/********************************************************************************

View file

@ -45,6 +45,7 @@ abstract class AbstractNamedDBElement extends AbstractDBElement implements Named
#[Assert\NotBlank]
#[Groups(['simple', 'extended', 'full', 'import', 'api:basic:read', 'api:basic:write'])]
#[ORM\Column(type: Types::STRING)]
#[Assert\Length(max: 255)]
protected string $name = '';
/******************************************************************************