/** * Validate Db_Row * * @param Gpf_DbEngine_Row $row * @throws Gpf_DbEngine_Row_ConstraintException */ public function validate(Gpf_DbEngine_Row $row) { $value = $row->get($this->columnName); if ($value == null || $value == "") { return; } if (preg_match($this->regExp, $value) != 1) { if ($this->message == "") { throw new Gpf_DbEngine_Row_ConstraintException($this->columnName, $this->_("Column %s contains unallowed characters", $this->columnName)); } throw new Gpf_DbEngine_Row_ConstraintException($this->columnName, Gpf_Lang::_replaceArgs($this->message, $value)); } }
/** * Validate Db_Row * * @param Gpf_DbEngine_Row $row * @throws Gpf_DbEngine_Row_ConstraintException */ public function validate(Gpf_DbEngine_Row $row) { if ($this->minLength == 0 && $this->maxLength == 0) { return; } if ($this->minLength > 0 && strlen($row->get($this->columnName)) < $this->minLength) { if ($this->minMessage == '') { throw new Gpf_DbEngine_Row_ConstraintException($this->columnName, $this->_('Minimum length of %s in %s is %s', $this->columnName, get_class($row), $this->minLength - 1)); } else { throw new Gpf_DbEngine_Row_ConstraintException($this->columnName, Gpf_Lang::_replaceArgs($this->minMessage, $this->minLength - 1)); } } if ($this->maxLength > 0 && strlen($row->get($this->columnName)) > $this->maxLength) { if ($this->maxMessage == '') { throw new Gpf_DbEngine_Row_ConstraintException($this->columnName, $this->_('Maximum length of %s in %s is %s', $this->columnName, get_class($row), $this->maxLength)); } else { throw new Gpf_DbEngine_Row_ConstraintException($this->columnName, Gpf_Lang::_replaceArgs($this->maxMessage, $this->maxLength)); } } }
private function translateFieldLabel(Gpf_Rpc_Form_Validator_Validator $validator) { return Gpf_Lang::_replaceArgs($validator->getText(), $this->fieldLabel); }