- Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
<?php
class Validator
{
private array $rules;
public function __construct(array $rules)
{
$this->rules = $rules;
}
public function validate (Enrollee $enrollee): ErrorList
{
$errorList = new ErrorList();
foreach ($this->rules as $fieldName => $checklist)
{
foreach ($checklist as $rule)
{
$result = $rule($enrollee->get($fieldName));
if ($result) {
$errorList->add($fieldName, $result);
}
}
}
return $errorList;
}
}