<?php

namespace App\Validator\Constraints;

use App\Model\OrganizationalUnitP2PModes;
use App\Model\UserGroupPermissions;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;

class OrganizationalUnitP2PModeValidator extends ConstraintValidator
{
    public function validate($value, Constraint $constraint): void
    {
        if (null === $value) {
            return;
        }

        if (!in_array($value, OrganizationalUnitP2PModes::getP2pModes())) {
            $this->context->buildViolation($constraint->message)->addViolation();
        }
    }
}