From 68e72057938af7e6e99b55ab0051ffcb2b91c1bf Mon Sep 17 00:00:00 2001 From: tristan Date: Tue, 23 Jun 2026 14:03:32 +0200 Subject: [PATCH] =?UTF-8?q?fix(back)=20:=20422=20de=20validation=20mappabl?= =?UTF-8?q?es=20+=20poids=20obligatoire=20sur=20le=20ticket=20de=20pes?= =?UTF-8?q?=C3=A9e=20(ERP-189)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - collectDenormalizationErrors sur Post/Patch : les erreurs de dénormalisation (date/type/IRI) reviennent en 422 avec propertyPath (et non 400 opaque), donc mappables inline côté front (miroir M1 Client). - NotBlank sur emptyWeight : le poids à vide est obligatoire à la création, sa violation est renvoyée avec counterpartyType / immatriculation d'un seul coup. --- .../Logistique/Domain/Entity/WeighingTicket.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Module/Logistique/Domain/Entity/WeighingTicket.php b/src/Module/Logistique/Domain/Entity/WeighingTicket.php index 5f412c7..7e6bf1d 100644 --- a/src/Module/Logistique/Domain/Entity/WeighingTicket.php +++ b/src/Module/Logistique/Domain/Entity/WeighingTicket.php @@ -95,6 +95,10 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; 'default:read', ]], denormalizationContext: ['groups' => ['weighing_ticket:write']], + // Erreurs de denormalisation (date non parsable, type/IRI invalide) + // remontees en 422 avec propertyPath (et non 400 opaque) -> mapping + // inline par champ cote front via useFormErrors (miroir M1 Client). + collectDenormalizationErrors: true, processor: WeighingTicketProcessor::class, ), new Patch( @@ -108,6 +112,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; 'default:read', ]], denormalizationContext: ['groups' => ['weighing_ticket:write']], + collectDenormalizationErrors: true, provider: WeighingTicketProvider::class, processor: WeighingTicketProcessor::class, ), @@ -190,8 +195,15 @@ class WeighingTicket implements TimestampableInterface, BlamableInterface #[Groups(['weighing_ticket:item:read', 'weighing_ticket:write'])] private ?DateTimeImmutable $emptyDate = null; - /** Poids a vide (tare) en kg — readonly UI, rempli par la pesee (RG-5.07). */ + /** + * Poids a vide (tare) en kg — readonly UI, rempli par la pesee (RG-5.07). + * Obligatoire : un ticket est cree APRES la pesee a vide (POST). NotBlank ici + * (et non sur empty_dsd, alloue serveur) rend la 422 « poids obligatoire » + * coherente avec les autres champs requis (counterpartyType / immatriculation), + * toutes renvoyees d'un coup -> mapping inline front (ERP-101). + */ #[ORM\Column(name: 'empty_weight', nullable: true)] + #[Assert\NotBlank(message: 'Le poids est obligatoire : effectuez une pesée.')] #[Groups(['weighing_ticket:item:read', 'weighing_ticket:write'])] private ?int $emptyWeight = null;