public function addRule(Rule $rule)
    {
        $classname = $rule->getClass();
        if ($this->hasRule($classname) === true) {
            throw new Exception(
                "failed to add rule; the field {$this->name} already has an ".
                "instance of '$classname'"
            );
        }
        else if ($classname === Rule::REQUIRED) {
            $this->rules = [$classname => $rule] + $this->rules;
        }
        else {
            $this->rules[$classname] = $rule;
        }
        return $this;
    }
public function addRule(Rule $rule)
    {
        $classname = $rule->getClass();
        if ($this->hasRule($classname) === true) {
            throw new Exception(
                "failed to add rule; the field {$this->name} already has an ".
                "instance of '$classname'"
            );
        }
        else if ($classname === Rule::REQUIRED) {
            $this->rules = [$classname => $rule] + $this->rules;
        }
        else {
            $this->rules[$classname] = $rule;
        }
        return $this;
    }
public function addRule ( Rule $ rule ) { $ classname = $ rule -> getClass ( ) ; if ( $ this -> hasRule ( $ classname ) === true ) { throw new Exception ( "failed to add rule; the field {$this->name} already has an " . "instance of '$classname'" ) ; } else if ( $ classname === Rule :: REQUIRED ) { $ this -> rules = [ $ classname => $ rule ] + $ this -> rules ; } else { $ this -> rules [ $ classname ] = $ rule ; } return $ this ; }
Add a validation rule to the field

@param \sndsgd\field\Rule $rule
@return \sndsgd\Field The field instance
Add a validation rule to the field