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

Breadcrumb

  1. Drupal Core 11.1.x
  2. Bic.php

class Bic

Ensures that the value is valid against the BIC format.

@author Michael Hirschler <michael.vhirsch@gmail.com>

Hierarchy

  • class \Symfony\Component\Validator\Constraint
    • class \Symfony\Component\Validator\Constraints\Bic extends \Symfony\Component\Validator\Constraint

Expanded class hierarchy of Bic

See also

https://en.wikipedia.org/wiki/ISO_9362

File

vendor/symfony/validator/Constraints/Bic.php, line 28

Namespace

Symfony\Component\Validator\Constraints
View source
class Bic extends Constraint {
    public const VALIDATION_MODE_STRICT = 'strict';
    public const VALIDATION_MODE_CASE_INSENSITIVE = 'case-insensitive';
    public const VALIDATION_MODES = [
        self::VALIDATION_MODE_STRICT,
        self::VALIDATION_MODE_CASE_INSENSITIVE,
    ];
    public const INVALID_LENGTH_ERROR = '66dad313-af0b-4214-8566-6c799be9789c';
    public const INVALID_CHARACTERS_ERROR = 'f424c529-7add-4417-8f2d-4b656e4833e2';
    
    /**
     * @deprecated since Symfony 7.1, to be removed in 8.0
     */
    public const INVALID_BANK_CODE_ERROR = '00559357-6170-4f29-aebd-d19330aa19cf';
    public const INVALID_COUNTRY_CODE_ERROR = '1ce76f8d-3c1f-451c-9e62-fe9c3ed486ae';
    public const INVALID_CASE_ERROR = '11884038-3312-4ae5-9d04-699f782130c7';
    public const INVALID_IBAN_COUNTRY_CODE_ERROR = '29a2c3bb-587b-4996-b6f5-53081364cea5';
    protected const ERROR_NAMES = [
        self::INVALID_LENGTH_ERROR => 'INVALID_LENGTH_ERROR',
        self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR',
        self::INVALID_BANK_CODE_ERROR => 'INVALID_BANK_CODE_ERROR',
        self::INVALID_COUNTRY_CODE_ERROR => 'INVALID_COUNTRY_CODE_ERROR',
        self::INVALID_CASE_ERROR => 'INVALID_CASE_ERROR',
    ];
    public string $message = 'This is not a valid Business Identifier Code (BIC).';
    public string $ibanMessage = 'This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.';
    public ?string $iban = null;
    public ?string $ibanPropertyPath = null;
    
    /**
     * @var self::VALIDATION_MODE_*
     */
    public string $mode = self::VALIDATION_MODE_STRICT;
    
    /**
     * @param array<string,mixed>|null     $options
     * @param string|null                  $iban             An IBAN value to validate that its country code is the same as the BIC's one
     * @param string|null                  $ibanPropertyPath Property path to the IBAN value when validating objects
     * @param string[]|null                $groups
     * @param self::VALIDATION_MODE_*|null $mode             The mode used to validate the BIC; pass null to use the default mode (strict)
     */
    public function __construct(?array $options = null, ?string $message = null, ?string $iban = null, ?string $ibanPropertyPath = null, ?string $ibanMessage = null, ?array $groups = null, mixed $payload = null, ?string $mode = null) {
        if (!class_exists(Countries::class)) {
            throw new LogicException('The Intl component is required to use the Bic constraint. Try running "composer require symfony/intl".');
        }
        if (\is_array($options) && \array_key_exists('mode', $options) && !\in_array($options['mode'], self::VALIDATION_MODES, true)) {
            throw new InvalidArgumentException('The "mode" parameter value is not valid.');
        }
        if (null !== $mode && !\in_array($mode, self::VALIDATION_MODES, true)) {
            throw new InvalidArgumentException('The "mode" parameter value is not valid.');
        }
        parent::__construct($options, $groups, $payload);
        $this->message = $message ?? $this->message;
        $this->ibanMessage = $ibanMessage ?? $this->ibanMessage;
        $this->iban = $iban ?? $this->iban;
        $this->ibanPropertyPath = $ibanPropertyPath ?? $this->ibanPropertyPath;
        $this->mode = $mode ?? $this->mode;
        if (null !== $this->iban && null !== $this->ibanPropertyPath) {
            throw new ConstraintDefinitionException('The "iban" and "ibanPropertyPath" options of the Iban constraint cannot be used at the same time.');
        }
        if (null !== $this->ibanPropertyPath && !class_exists(PropertyAccess::class)) {
            throw new LogicException(\sprintf('The "symfony/property-access" component is required to use the "%s" constraint with the "ibanPropertyPath" option. Try running "composer require symfony/property-access".', self::class));
        }
    }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title Overrides
Bic::$iban public property
Bic::$ibanMessage public property
Bic::$ibanPropertyPath public property
Bic::$message public property
Bic::$mode public property
Bic::ERROR_NAMES protected constant Maps error codes to the names of their constants. Overrides Constraint::ERROR_NAMES
Bic::INVALID_BANK_CODE_ERROR Deprecated public constant
Bic::INVALID_CASE_ERROR public constant
Bic::INVALID_CHARACTERS_ERROR public constant
Bic::INVALID_COUNTRY_CODE_ERROR public constant
Bic::INVALID_IBAN_COUNTRY_CODE_ERROR public constant
Bic::INVALID_LENGTH_ERROR public constant
Bic::VALIDATION_MODES public constant
Bic::VALIDATION_MODE_CASE_INSENSITIVE public constant
Bic::VALIDATION_MODE_STRICT public constant
Bic::__construct public function Overrides Constraint::__construct
Constraint::$groups public property The groups that the constraint belongs to.
Constraint::$payload public property Domain-specific data attached to a constraint.
Constraint::addImplicitGroupName public function Adds the given group if this constraint is in the Default group. 2
Constraint::CLASS_CONSTRAINT public constant Marks a constraint that can be put onto classes.
Constraint::DEFAULT_GROUP public constant The name of the group given to all constraints with no explicit group.
Constraint::getDefaultOption public function Returns the name of the default option. 28
Constraint::getErrorName public static function Returns the name of the given error code.
Constraint::getRequiredOptions public function Returns the name of the required options. 22
Constraint::getTargets public function Returns whether the constraint can be put onto classes, properties or
both.
8
Constraint::normalizeOptions protected function
Constraint::PROPERTY_CONSTRAINT public constant Marks a constraint that can be put onto properties.
Constraint::validatedBy public function Returns the name of the class that validates this constraint. 9
Constraint::__get public function Returns the value of a lazily initialized option. 2
Constraint::__isset public function 1
Constraint::__set public function Sets the value of a lazily initialized option. 1
Constraint::__sleep public function Optimizes the serialized value to minimize storage space.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal