summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Api/Action.php2
-rw-r--r--app/Controller/Action.php2
-rw-r--r--app/Controller/Column.php4
-rw-r--r--app/Core/Base.php2
-rw-r--r--app/Model/Action.php26
-rw-r--r--app/Model/ActionParameter.php3
-rw-r--r--app/Model/Board.php45
-rw-r--r--app/ServiceProvider/ClassProvider.php2
-rw-r--r--app/Validator/ActionValidator.php38
-rw-r--r--app/Validator/ColumnValidator.php58
10 files changed, 104 insertions, 78 deletions
diff --git a/app/Api/Action.php b/app/Api/Action.php
index bdb5b26e..9e3b86f6 100644
--- a/app/Api/Action.php
+++ b/app/Api/Action.php
@@ -44,7 +44,7 @@ class Action extends \Kanboard\Core\Base
'params' => $params,
);
- list($valid, ) = $this->action->validateCreation($values);
+ list($valid, ) = $this->actionValidator->validateCreation($values);
if (! $valid) {
return false;
diff --git a/app/Controller/Action.php b/app/Controller/Action.php
index 9b803893..645b53b7 100644
--- a/app/Controller/Action.php
+++ b/app/Controller/Action.php
@@ -116,7 +116,7 @@ class Action extends Base
*/
private function doCreation(array $project, array $values)
{
- list($valid, ) = $this->action->validateCreation($values);
+ list($valid, ) = $this->actionValidator->validateCreation($values);
if ($valid) {
if ($this->action->create($values) !== false) {
diff --git a/app/Controller/Column.php b/app/Controller/Column.php
index b484fe12..1ce575d7 100644
--- a/app/Controller/Column.php
+++ b/app/Controller/Column.php
@@ -51,7 +51,7 @@ class Column extends Base
$values['title['.$column_id.']'] = $column_title;
}
- list($valid, $errors) = $this->board->validateCreation($data);
+ list($valid, $errors) = $this->columnValidator->validateCreation($data);
if ($valid) {
if ($this->board->addColumn($project['id'], $data['title'], $data['task_limit'], $data['description'])) {
@@ -94,7 +94,7 @@ class Column extends Base
$project = $this->getProject();
$values = $this->request->getValues();
- list($valid, $errors) = $this->board->validateModification($values);
+ list($valid, $errors) = $this->columnValidator->validateModification($values);
if ($valid) {
if ($this->board->updateColumn($values['id'], $values['title'], $values['task_limit'], $values['description'])) {
diff --git a/app/Core/Base.php b/app/Core/Base.php
index 723831e3..22f09403 100644
--- a/app/Core/Base.php
+++ b/app/Core/Base.php
@@ -113,6 +113,8 @@ use Pimple\Container;
* @property \Kanboard\Model\UserUnreadNotification $userUnreadNotification
* @property \Kanboard\Model\UserMetadata $userMetadata
* @property \Kanboard\Model\Webhook $webhook
+ * @property \Kanboard\Validator\ActionValidator $actionValidator
+ * @property \Kanboard\Validator\ColumnValidator $columnValidator
* @property \Kanboard\Validator\PasswordResetValidator $passwordResetValidator
* @property \Kanboard\Validator\ProjectValidator $projectValidator
* @property \Kanboard\Validator\SubtaskValidator $subtaskValidator
diff --git a/app/Model/Action.php b/app/Model/Action.php
index 5fcfbaa7..4da2fb8f 100644
--- a/app/Model/Action.php
+++ b/app/Model/Action.php
@@ -2,9 +2,6 @@
namespace Kanboard\Model;
-use SimpleValidator\Validator;
-use SimpleValidator\Validators;
-
/**
* Action Model
*
@@ -188,27 +185,4 @@ class Action extends Base
return true;
}
-
- /**
- * Validate action creation
- *
- * @access public
- * @param array $values Required parameters to save an action
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validateCreation(array $values)
- {
- $v = new Validator($values, array(
- new Validators\Required('project_id', t('The project id is required')),
- new Validators\Integer('project_id', t('This value must be an integer')),
- new Validators\Required('event_name', t('This value is required')),
- new Validators\Required('action_name', t('This value is required')),
- new Validators\Required('params', t('This value is required')),
- ));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
}
diff --git a/app/Model/ActionParameter.php b/app/Model/ActionParameter.php
index 1e4d7544..62b03142 100644
--- a/app/Model/ActionParameter.php
+++ b/app/Model/ActionParameter.php
@@ -2,9 +2,6 @@
namespace Kanboard\Model;
-use SimpleValidator\Validator;
-use SimpleValidator\Validators;
-
/**
* Action Parameter Model
*
diff --git a/app/Model/Board.php b/app/Model/Board.php
index 79a1a92d..0f980f68 100644
--- a/app/Model/Board.php
+++ b/app/Model/Board.php
@@ -2,8 +2,6 @@
namespace Kanboard\Model;
-use SimpleValidator\Validator;
-use SimpleValidator\Validators;
use PicoDb\Database;
/**
@@ -436,47 +434,4 @@ class Board extends Base
{
return $this->db->table(self::TABLE)->eq('id', $column_id)->remove();
}
-
- /**
- * Validate column modification
- *
- * @access public
- * @param array $values Required parameters to update a column
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validateModification(array $values)
- {
- $v = new Validator($values, array(
- new Validators\Integer('task_limit', t('This value must be an integer')),
- new Validators\Required('title', t('The title is required')),
- new Validators\MaxLength('title', t('The maximum length is %d characters', 50), 50),
- ));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
-
- /**
- * Validate column creation
- *
- * @access public
- * @param array $values Required parameters to save an action
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validateCreation(array $values)
- {
- $v = new Validator($values, array(
- new Validators\Required('project_id', t('The project id is required')),
- new Validators\Integer('project_id', t('This value must be an integer')),
- new Validators\Required('title', t('The title is required')),
- new Validators\MaxLength('title', t('The maximum length is %d characters', 50), 50),
- ));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
}
diff --git a/app/ServiceProvider/ClassProvider.php b/app/ServiceProvider/ClassProvider.php
index bb9e757e..61c97a07 100644
--- a/app/ServiceProvider/ClassProvider.php
+++ b/app/ServiceProvider/ClassProvider.php
@@ -85,6 +85,8 @@ class ClassProvider implements ServiceProviderInterface
'GroupAutoCompleteFormatter',
),
'Validator' => array(
+ 'ActionValidator',
+ 'ColumnValidator',
'PasswordResetValidator',
'ProjectValidator',
'SubtaskValidator',
diff --git a/app/Validator/ActionValidator.php b/app/Validator/ActionValidator.php
new file mode 100644
index 00000000..95ee7d21
--- /dev/null
+++ b/app/Validator/ActionValidator.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Kanboard\Validator;
+
+use SimpleValidator\Validator;
+use SimpleValidator\Validators;
+
+/**
+ * Action Validator
+ *
+ * @package validator
+ * @author Frederic Guillot
+ */
+class ActionValidator extends Base
+{
+ /**
+ * Validate action creation
+ *
+ * @access public
+ * @param array $values Required parameters to save an action
+ * @return array $valid, $errors [0] = Success or not, [1] = List of errors
+ */
+ public function validateCreation(array $values)
+ {
+ $v = new Validator($values, array(
+ new Validators\Required('project_id', t('The project id is required')),
+ new Validators\Integer('project_id', t('This value must be an integer')),
+ new Validators\Required('event_name', t('This value is required')),
+ new Validators\Required('action_name', t('This value is required')),
+ new Validators\Required('params', t('This value is required')),
+ ));
+
+ return array(
+ $v->execute(),
+ $v->getErrors()
+ );
+ }
+}
diff --git a/app/Validator/ColumnValidator.php b/app/Validator/ColumnValidator.php
new file mode 100644
index 00000000..4c644e8a
--- /dev/null
+++ b/app/Validator/ColumnValidator.php
@@ -0,0 +1,58 @@
+<?php
+
+namespace Kanboard\Validator;
+
+use SimpleValidator\Validator;
+use SimpleValidator\Validators;
+
+/**
+ * Column Validator
+ *
+ * @package validator
+ * @author Frederic Guillot
+ */
+class ColumnValidator extends Base
+{
+ /**
+ * Validate column modification
+ *
+ * @access public
+ * @param array $values Required parameters to update a column
+ * @return array $valid, $errors [0] = Success or not, [1] = List of errors
+ */
+ public function validateModification(array $values)
+ {
+ $v = new Validator($values, array(
+ new Validators\Integer('task_limit', t('This value must be an integer')),
+ new Validators\Required('title', t('The title is required')),
+ new Validators\MaxLength('title', t('The maximum length is %d characters', 50), 50),
+ ));
+
+ return array(
+ $v->execute(),
+ $v->getErrors()
+ );
+ }
+
+ /**
+ * Validate column creation
+ *
+ * @access public
+ * @param array $values Required parameters to save an action
+ * @return array $valid, $errors [0] = Success or not, [1] = List of errors
+ */
+ public function validateCreation(array $values)
+ {
+ $v = new Validator($values, array(
+ new Validators\Required('project_id', t('The project id is required')),
+ new Validators\Integer('project_id', t('This value must be an integer')),
+ new Validators\Required('title', t('The title is required')),
+ new Validators\MaxLength('title', t('The maximum length is %d characters', 50), 50),
+ ));
+
+ return array(
+ $v->execute(),
+ $v->getErrors()
+ );
+ }
+}