diff --git a/src/Dto/Matchfunding/MatchCallSubmissionCreationDto.php b/src/Dto/Matchfunding/MatchCallSubmissionCreationDto.php index 64827d8..9299538 100644 --- a/src/Dto/Matchfunding/MatchCallSubmissionCreationDto.php +++ b/src/Dto/Matchfunding/MatchCallSubmissionCreationDto.php @@ -4,8 +4,10 @@ namespace App\Dto\Matchfunding; use App\ApiResource\Matchfunding\MatchCallApiResource; use App\ApiResource\Project\ProjectApiResource; +use App\Validator\SingleProjectSubmissionPerCall; use Symfony\Component\Validator\Constraints as Assert; +#[SingleProjectSubmissionPerCall()] class MatchCallSubmissionCreationDto { /** diff --git a/src/Validator/SingleProjectSubmissionPerCall.php b/src/Validator/SingleProjectSubmissionPerCall.php new file mode 100644 index 0000000..573374a --- /dev/null +++ b/src/Validator/SingleProjectSubmissionPerCall.php @@ -0,0 +1,24 @@ +matchCallSubmissionRepository->findOneBy([ + 'call' => $value->call->id, + 'project' => $value->project->id + ]); + + if ($submission === null) { + return; + } + + $this->context->buildViolation($constraint->message) + ->addViolation() + ; + } +}