db->getConnection(), ProjectModel::TABLE), new Validators\Email('email', t('Email address invalid')) , new Validators\Unique('email', t('The email project must be unique across all projects'), $this->db->getConnection(), ProjectModel::TABLE), ); } /** * Validate project creation * * @access public * @param array $values Form values * @return array $valid, $errors [0] = Success or not, [1] = List of errors */ public function validateCreation(array $values) { if (! empty($values['identifier'])) { $values['identifier'] = strtoupper($values['identifier']); } $rules = array( new Validators\Required('name', t('The project name is required')), ); $v = new Validator($values, array_merge($rules, $this->commonValidationRules())); return array( $v->execute(), $v->getErrors() ); } /** * Validate project modification * * @access public * @param array $values Form values * @return array $valid, $errors [0] = Success or not, [1] = List of errors */ public function validateModification(array $values) { if (! empty($values['identifier'])) { $values['identifier'] = strtoupper($values['identifier']); } $rules = array( new Validators\NotEmpty('name', t('This field cannot be empty')), new Validators\Required('id', t('This value is required')), ); $v = new Validator($values, array_merge($rules, $this->commonValidationRules())); return array( $v->execute(), $v->getErrors() ); } }