Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

AtLeastOneOf.php

Namespace

Symfony\Component\Validator\Constraints

File

vendor/symfony/validator/Constraints/AtLeastOneOf.php

View source
<?php


/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Constraint;

/**
 * Checks that at least one of the given constraint is satisfied.
 *
 * @author Przemysław Bogusz <przemyslaw.bogusz@tubotax.pl>
 */
class AtLeastOneOf extends Composite {
    public const AT_LEAST_ONE_OF_ERROR = 'f27e6d6c-261a-4056-b391-6673a623531c';
    protected const ERROR_NAMES = [
        self::AT_LEAST_ONE_OF_ERROR => 'AT_LEAST_ONE_OF_ERROR',
    ];
    public array|Constraint $constraints = [];
    public string $message = 'This value should satisfy at least one of the following constraints:';
    public string $messageCollection = 'Each element of this collection should satisfy its own set of constraints.';
    public bool $includeInternalMessages = true;
    
    /**
     * @param array<Constraint>|array<string,mixed>|null $constraints             An array of validation constraints
     * @param string[]|null                              $groups
     * @param string|null                                $message                 Intro of the failure message that will be followed by the failed constraint(s) message(s)
     * @param string|null                                $messageCollection       Failure message for All and Collection inner constraints
     * @param bool|null                                  $includeInternalMessages Whether to include inner constraint messages (defaults to true)
     */
    public function __construct(mixed $constraints = null, ?array $groups = null, mixed $payload = null, ?string $message = null, ?string $messageCollection = null, ?bool $includeInternalMessages = null) {
        parent::__construct($constraints ?? [], $groups, $payload);
        $this->message = $message ?? $this->message;
        $this->messageCollection = $messageCollection ?? $this->messageCollection;
        $this->includeInternalMessages = $includeInternalMessages ?? $this->includeInternalMessages;
    }
    public function getDefaultOption() : ?string {
        return 'constraints';
    }
    public function getRequiredOptions() : array {
        return [
            'constraints',
        ];
    }
    protected function getCompositeOption() : string {
        return 'constraints';
    }

}

Classes

Title Deprecated Summary
AtLeastOneOf Checks that at least one of the given constraint is satisfied.
RSS feed
Powered by Drupal