summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-01-11 22:07:39 -0500
committerFrederic Guillot <fred@kanboard.net>2016-01-11 22:07:39 -0500
commit3699073371acc66ccacb56a89e87147a9c90d8c4 (patch)
treec21c55936e472655aaa5aca3a976a2d02a0ed63a /app/Model
parente31185a2bd85d7d8e16a614cb21dfdbff10ce070 (diff)
Move project validator methods
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/Project.php69
1 files changed, 0 insertions, 69 deletions
diff --git a/app/Model/Project.php b/app/Model/Project.php
index 8a949ba6..63077348 100644
--- a/app/Model/Project.php
+++ b/app/Model/Project.php
@@ -2,8 +2,6 @@
namespace Kanboard\Model;
-use SimpleValidator\Validator;
-use SimpleValidator\Validators;
use Kanboard\Core\Security\Token;
use Kanboard\Core\Security\Role;
@@ -510,71 +508,4 @@ class Project extends Base
->eq('id', $project_id)
->save(array('is_public' => 0, 'token' => ''));
}
-
- /**
- * Common validation rules
- *
- * @access private
- * @return array
- */
- private function commonValidationRules()
- {
- return array(
- new Validators\Integer('id', t('This value must be an integer')),
- new Validators\Integer('is_active', t('This value must be an integer')),
- new Validators\Required('name', t('The project name is required')),
- 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(), self::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']);
- }
-
- $v = new Validator($values, $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\Required('id', t('This value is required')),
- );
-
- $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
}