public function addValidator($data)
    {
        if ($data instanceof Validator) {
            $validator = $data;
            $col = $this->getColumn($validator->getColumnName());
            if ($col == null) {
                throw new EngineException("Failed adding validator to table '" . $this->getName() . "': column '" . $validator->getColumnName() . "' does not exist !");
            }
            $validator->setColumn($col);
            $validator->setTable($this);
            $this->validatorList[] = $validator;

            return $validator;
        } else {
            $validator = new Validator();
            $validator->setTable($this);
            $validator->loadFromXML($data);

            return $this->addValidator($validator);
        }
    }
public function addValidator($data)
    {
        if ($data instanceof Validator) {
            $validator = $data;
            $col = $this->getColumn($validator->getColumnName());
            if ($col == null) {
                throw new EngineException("Failed adding validator to table '" . $this->getName() . "': column '" . $validator->getColumnName() . "' does not exist !");
            }
            $validator->setColumn($col);
            $validator->setTable($this);
            $this->validatorList[] = $validator;

            return $validator;
        } else {
            $validator = new Validator();
            $validator->setTable($this);
            $validator->loadFromXML($data);

            return $this->addValidator($validator);
        }
    }
public function addValidator ( $ data ) { if ( $ data instanceof Validator ) { $ validator = $ data ; $ col = $ this -> getColumn ( $ validator -> getColumnName ( ) ) ; if ( $ col == null ) { throw new EngineException ( "Failed adding validator to table '" . $ this -> getName ( ) . "': column '" . $ validator -> getColumnName ( ) . "' does not exist !" ) ; } $ validator -> setColumn ( $ col ) ; $ validator -> setTable ( $ this ) ; $ this -> validatorList [ ] = $ validator ; return $ validator ; } else { $ validator = new Validator ( ) ; $ validator -> setTable ( $ this ) ; $ validator -> loadFromXML ( $ data ) ; return $ this -> addValidator ( $ validator ) ; } }
Add a validator to this table.

Supports two signatures:
- addValidator(Validator $validator)
- addValidator(array $attribs)

@param mixed $data Validator object or XML attribs (array) from <validator /> element.

@return Validator       The added Validator.
@throws EngineException
Add a validator to this table .