function Constraint::__construct
Same name in this branch
- 11.1.x vendor/composer/semver/src/Constraint/Constraint.php \Composer\Semver\Constraint\Constraint::__construct()
- 11.1.x core/lib/Drupal/Core/Validation/Attribute/Constraint.php \Drupal\Core\Validation\Attribute\Constraint::__construct()
- 11.1.x core/lib/Drupal/Component/Version/Constraint.php \Drupal\Component\Version\Constraint::__construct()
Initializes the constraint with options.
You should pass an associative array. The keys should be the names of existing properties in this class. The values should be the value for these properties.
Alternatively you can override the method getDefaultOption() to return the name of an existing property. If no associative array is passed, this property is set instead.
You can force that certain options are set by overriding getRequiredOptions() to return the names of these options. If any option is not set here, an exception is thrown.
Parameters
mixed $options The options (as associative array): or the value for the default option (any other type)
string[] $groups An array of validation groups:
mixed $payload Domain-specific data attached to a constraint:
Throws
InvalidOptionsException When you pass the names of non-existing options
MissingOptionsException When you don't pass any of the options returned by getRequiredOptions()
ConstraintDefinitionException When you don't pass an associative array, but getDefaultOption() returns null
116 calls to Constraint::__construct()
- AbstractComparison::__construct in vendor/
symfony/ validator/ Constraints/ AbstractComparison.php - Initializes the constraint with options.
- AbstractComparison::__construct in vendor/
symfony/ validator/ Constraints/ AbstractComparison.php - Initializes the constraint with options.
- Bic::__construct in vendor/
symfony/ validator/ Constraints/ Bic.php - Bic::__construct in vendor/
symfony/ validator/ Constraints/ Bic.php - Blank::__construct in vendor/
symfony/ validator/ Constraints/ Blank.php
58 methods override Constraint::__construct()
- AbstractComparison::__construct in vendor/
symfony/ validator/ Constraints/ AbstractComparison.php - Initializes the constraint with options.
- Bic::__construct in vendor/
symfony/ validator/ Constraints/ Bic.php - Blank::__construct in vendor/
symfony/ validator/ Constraints/ Blank.php - Callback::__construct in vendor/
symfony/ validator/ Constraints/ Callback.php - CardScheme::__construct in vendor/
symfony/ validator/ Constraints/ CardScheme.php
File
-
vendor/
symfony/ validator/ Constraint.php, line 109
Class
- Constraint
- Contains the properties of a constraint definition.
Namespace
Symfony\Component\ValidatorCode
public function __construct(mixed $options = null, ?array $groups = null, mixed $payload = null) {
unset($this->groups);
// enable lazy initialization
$options = $this->normalizeOptions($options);
if (null !== $groups) {
$options['groups'] = $groups;
}
$options['payload'] = $payload ?? $options['payload'] ?? null;
foreach ($options as $name => $value) {
$this->{$name} = $value;
}
}