$ruleSet =
[ $field =>
[ 'label' =>
$label,
'rules' =>
$rules,
],
];
if ($errors) { $ruleSet[$field]['errors'
] =
$errors;
} $this->
setRules(array_merge($this->
getRules(),
$ruleSet),
$this->customErrors
);
return $this;
} /**
* Stores the rules that should be used to validate the items.
*
* Rules should be an array formatted like:
* [
* 'field' => 'rule1|rule2'
* ]
*
* The $errors array should be formatted like:
* [
* 'field' => [
* 'rule1' => 'message1',
* 'rule2' => 'message2',
* ],
* ]
*
* @param array $errors An array of custom error messages
*/