Gdn_Validation::applyRuleTo PHP Method

applyRuleTo() protected method

Apply a rule to the given rules array.
protected applyRuleTo ( array &$Array, string $FieldName, string $RuleName, string $CustomError = '' )
$Array array The rules array to apply the rule to. This should be either `$this->_FieldRules` or `$this->_SchemaRules`.
$FieldName string The name of the field that the rule applies to.
$RuleName string The name of the rule.
$CustomError string A custom error string when the rule is broken.
    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));
    }