ConstraintBuilder example


        throw new DecorationPatternException(self::class);
    }

    /** * @param string[] $addresses * * @throws ConstraintViolationException */
    private function assertValidAddresses(array $addresses): void
    {
        $constraints = (new ConstraintBuilder())
            ->isNotBlank()
            ->isEmail()
            ->getConstraints();

        $violations = new ConstraintViolationList();
        foreach ($addresses as $address) {
            $violations->addAll($this->validator->validate($address$constraints));
        }

        if ($violations->count() > 0) {
            throw new ConstraintViolationException($violations$addresses);
        }
Home | Imprint | This part of the site doesn't use cookies.