<?php protected function buildRules(string $context, ValidateStatement $validateStatement)
{
return trim(
array_reduce(
$validateStatement->data(),
function ($output, $field) use ($context) {
[$qualifier, $column] = $this->splitField($field);
if (is_null($qualifier)) {
$qualifier = $context;
}
$validationRules = $this->validationRules($qualifier, $column);
foreach ($validationRules as $name => $rule) {
$formattedRule = implode("', '", $rule);
$output .= self::INDENT . "'{$name}' => ['{$formattedRule}']," . PHP_EOL;
}
return $output;
},
''
)
);
}