diff --git a/src/Adherent/Unregistration/UnregistrationCommand.php b/src/Adherent/Unregistration/UnregistrationCommand.php index ec904a83a7..1e0fd1e445 100644 --- a/src/Adherent/Unregistration/UnregistrationCommand.php +++ b/src/Adherent/Unregistration/UnregistrationCommand.php @@ -9,12 +9,13 @@ class UnregistrationCommand { - #[Assert\Choice(choices: Unregistration::REASONS_LIST_ADHERENT, multiple: true, groups: ['unregister'])] - #[Assert\NotBlank(message: 'adherent.unregistration.reasons')] + #[Assert\Choice(choices: Unregistration::REASONS_LIST_ADHERENT, multiple: true, groups: ['unregister_adherent'])] + #[Assert\Choice(choices: Unregistration::REASONS_LIST_USER, multiple: true, groups: ['unregister_user'])] + #[Assert\NotBlank(message: 'adherent.unregistration.reasons', groups: ['unregister'])] #[Groups('unregister')] private array $reasons; - #[Assert\Length(max: 1000, groups: ['Default', 'admin'])] + #[Assert\Length(max: 1000, groups: ['Default', 'admin', 'unregister'])] #[Groups('unregister')] private ?string $comment; diff --git a/src/Controller/Api/ProfileController.php b/src/Controller/Api/ProfileController.php index 56505a7a05..eb3370d2c6 100644 --- a/src/Controller/Api/ProfileController.php +++ b/src/Controller/Api/ProfileController.php @@ -269,7 +269,13 @@ public function terminateMembershipAction( ], ]); - $violations = $validator->validate($unregistrationCommand, null, ['unregister']); + $validationGroups = [$user->isAdherent() ? 'unregister_adherent' : 'unregister_user']; + + if ($user->getAuthAppVersion() >= 590) { + $validationGroups[] = 'unregister'; + } + + $violations = $validator->validate($unregistrationCommand, null, $validationGroups); if (0 < $violations->count()) { $errors = $serializer->serialize($violations, 'jsonproblem');