protected function applyRuleTo(&$Array, $FieldName, $RuleName, $CustomError = '')
{
$Array = (array) $Array;
if (!is_array($RuleName)) {
if ($CustomError != '') {
$this->_CustomErrors[$FieldName . '.' . $RuleName] = $CustomError;
}
$RuleName = array($RuleName);
}
$ExistingRules = val($FieldName, $Array, array());
// Merge the new rules with the existing ones (array_merge) and make
// sure there is only one of each rule applied (array_unique).
$Array[$FieldName] = array_unique(array_merge($ExistingRules, $RuleName));
}