Fixed: [budget] force budget kind and resource kind to have a unique kind field in database

This commit is contained in:
2023-02-09 18:08:20 +01:00
parent 9e63480c70
commit 2d013e110a
7 changed files with 72 additions and 5 deletions

View File

@@ -12,12 +12,17 @@ declare(strict_types=1);
namespace Chill\BudgetBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Type of charge.
*
* @ORM\Table(name="chill_budget.charge_type")
* @ORM\Table(name="chill_budget.charge_type",
* uniqueConstraints={@ORM\UniqueConstraint(name="charge_kind_unique_type_idx", fields={"kind"})}
* )
* @ORM\Entity
* @UniqueEntity(fields={"kind"})
*/
class ChargeKind
{
@@ -35,6 +40,8 @@ class ChargeKind
/**
* @ORM\Column(type="string", length=255, options={"default": ""}, nullable=false)
* @Assert\Regex(pattern="/^[a-z0-9\-_]{1,}$/", message="budget.admin.form.kind.only_alphanumeric")
* @Assert\Length(min=3)
*/
private string $kind = '';