function ValidKeysConstraint::__construct

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ValidKeysConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\ValidKeysConstraint::__construct()

Constructs a ValidKeysConstraint object.

Parameters

array|string $allowedKeys: Keys which are allowed in the validated array, or `<infer>` to auto-detect.

string $invalidKeyMessage: Error message for an invalid key.

string $dynamicInvalidKeyMessage: Error message for a dynamically invalid key.

string $missingRequiredKeyMessage: Error message for a missing required key.

string $dynamicMissingRequiredKeyMessage: Error message for a missing dynamic required key.

string $indexedArrayMessage: Error message if the array is numerically indexed.

array|null $groups: The groups that the constraint belongs to.

mixed|null $payload: Domain-specific data attached to a constraint.

File

core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ValidKeysConstraint.php, line 45

Class

ValidKeysConstraint
Checks that all the keys of a mapping are valid and required keys present.

Namespace

Drupal\Core\Validation\Plugin\Validation\Constraint

Code

public function __construct(public array|string $allowedKeys, public string $invalidKeyMessage = "'@key' is not a supported key.", public string $dynamicInvalidKeyMessage = "'@key' is an unknown key because @dynamic_type_property_path is @dynamic_type_property_value (see config schema type @resolved_dynamic_type).", public string $missingRequiredKeyMessage = "'@key' is a required key.", public string $dynamicMissingRequiredKeyMessage = "'@key' is a required key because @dynamic_type_property_path is @dynamic_type_property_value (see config schema type @resolved_dynamic_type).", public string $indexedArrayMessage = 'Numerically indexed arrays are not allowed.', ?array $groups = NULL, mixed $payload = NULL) {
  parent::__construct(groups: $groups, payload: $payload);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.