diff options
Diffstat (limited to 'app/Validator/ProjectValidator.php')
-rw-r--r-- | app/Validator/ProjectValidator.php | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/app/Validator/ProjectValidator.php b/app/Validator/ProjectValidator.php index 8c6117a4..8d8053a3 100644 --- a/app/Validator/ProjectValidator.php +++ b/app/Validator/ProjectValidator.php @@ -28,13 +28,14 @@ class ProjectValidator extends BaseValidator new Validators\Integer('priority_start', t('This value must be an integer')), new Validators\Integer('priority_end', t('This value must be an integer')), new Validators\Integer('is_active', t('This value must be an integer')), - new Validators\NotEmpty('name', t('This field cannot be empty')), new Validators\MaxLength('name', t('The maximum length is %d characters', 50), 50), new Validators\MaxLength('identifier', t('The maximum length is %d characters', 50), 50), new Validators\MaxLength('start_date', t('The maximum length is %d characters', 10), 10), new Validators\MaxLength('end_date', t('The maximum length is %d characters', 10), 10), new Validators\AlphaNumeric('identifier', t('This value must be alphanumeric')) , new Validators\Unique('identifier', t('The identifier must be unique'), $this->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), ); } @@ -47,15 +48,15 @@ class ProjectValidator extends BaseValidator */ public function validateCreation(array $values) { - $rules = array( - new Validators\Required('name', t('The project name is required')), - ); - if (! empty($values['identifier'])) { $values['identifier'] = strtoupper($values['identifier']); } - $v = new Validator($values, array_merge($this->commonValidationRules(), $rules)); + $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(), @@ -77,6 +78,7 @@ class ProjectValidator extends BaseValidator } $rules = array( + new Validators\NotEmpty('name', t('This field cannot be empty')), new Validators\Required('id', t('This value is required')), ); |