/**
* @param array<string, mixed> $elementConfig
*
* @return array<int, Constraint>
*/
private function buildConstraintsWithConfigs(array
$elementConfig): array
{ /** @var array<string, callable(mixed): Constraint> $constraints */
$constraints =
[ 'minLength' =>
fn (mixed
$ruleValue) =>
new Assert\
Length(['min' =>
$ruleValue]),
'maxLength' =>
fn (mixed
$ruleValue) =>
new Assert\
Length(['max' =>
$ruleValue]),
'min' =>
fn (mixed
$ruleValue) =>
new Assert\
Range(['min' =>
$ruleValue]),
'max' =>
fn (mixed
$ruleValue) =>
new Assert\
Range(['max' =>
$ruleValue]),
'dataType' =>
fn (mixed
$ruleValue) =>
new Assert\
Type($ruleValue),
'required' =>
fn (mixed
$ruleValue) =>
new Assert\
NotBlank(),
];
$constraintsResult =
[];
foreach ($constraints as $ruleName =>
$constraint) { if (!\
array_key_exists($ruleName,
$elementConfig)) { continue;
}