summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Api/Category.php4
-rw-r--r--app/Api/Comment.php4
-rw-r--r--app/Api/Link.php4
-rw-r--r--app/Controller/Auth.php2
-rw-r--r--app/Controller/Category.php4
-rw-r--r--app/Controller/Comment.php4
-rw-r--r--app/Controller/Currency.php2
-rw-r--r--app/Controller/Customfilter.php4
-rw-r--r--app/Controller/Group.php4
-rw-r--r--app/Controller/Link.php4
-rw-r--r--app/Core/Base.php9
-rw-r--r--app/Model/Category.php62
-rw-r--r--app/Model/Comment.php61
-rw-r--r--app/Model/Currency.php23
-rw-r--r--app/Model/CustomFilter.php62
-rw-r--r--app/Model/Group.php55
-rw-r--r--app/Model/Link.php45
-rw-r--r--app/ServiceProvider/ClassProvider.php8
-rw-r--r--app/Validator/AuthValidator.php (renamed from app/Model/Authentication.php)8
-rw-r--r--app/Validator/CategoryValidator.php74
-rw-r--r--app/Validator/CommentValidator.php74
-rw-r--r--app/Validator/CurrencyValidator.php35
-rw-r--r--app/Validator/CustomFilterValidator.php74
-rw-r--r--app/Validator/GroupValidator.php71
-rw-r--r--app/Validator/LinkValidator.php59
25 files changed, 424 insertions, 332 deletions
diff --git a/app/Api/Category.php b/app/Api/Category.php
index 458eaef6..fbd61c56 100644
--- a/app/Api/Category.php
+++ b/app/Api/Category.php
@@ -32,7 +32,7 @@ class Category extends \Kanboard\Core\Base
'name' => $name,
);
- list($valid, ) = $this->category->validateCreation($values);
+ list($valid, ) = $this->categoryValidator->validateCreation($values);
return $valid ? $this->category->create($values) : false;
}
@@ -43,7 +43,7 @@ class Category extends \Kanboard\Core\Base
'name' => $name,
);
- list($valid, ) = $this->category->validateModification($values);
+ list($valid, ) = $this->categoryValidator->validateModification($values);
return $valid && $this->category->update($values);
}
}
diff --git a/app/Api/Comment.php b/app/Api/Comment.php
index 4c4027c0..1fc1c708 100644
--- a/app/Api/Comment.php
+++ b/app/Api/Comment.php
@@ -34,7 +34,7 @@ class Comment extends \Kanboard\Core\Base
'reference' => $reference,
);
- list($valid, ) = $this->comment->validateCreation($values);
+ list($valid, ) = $this->commentValidator->validateCreation($values);
return $valid ? $this->comment->create($values) : false;
}
@@ -46,7 +46,7 @@ class Comment extends \Kanboard\Core\Base
'comment' => $content,
);
- list($valid, ) = $this->comment->validateModification($values);
+ list($valid, ) = $this->commentValidator->validateModification($values);
return $valid && $this->comment->update($values);
}
}
diff --git a/app/Api/Link.php b/app/Api/Link.php
index d4df18fe..23a9916d 100644
--- a/app/Api/Link.php
+++ b/app/Api/Link.php
@@ -72,7 +72,7 @@ class Link extends \Kanboard\Core\Base
'opposite_label' => $opposite_label,
);
- list($valid, ) = $this->link->validateCreation($values);
+ list($valid, ) = $this->linkValidator->validateCreation($values);
return $valid ? $this->link->create($label, $opposite_label) : false;
}
@@ -93,7 +93,7 @@ class Link extends \Kanboard\Core\Base
'label' => $label,
);
- list($valid, ) = $this->link->validateModification($values);
+ list($valid, ) = $this->linkValidator->validateModification($values);
return $valid && $this->link->update($values);
}
diff --git a/app/Controller/Auth.php b/app/Controller/Auth.php
index 07e66070..5284e126 100644
--- a/app/Controller/Auth.php
+++ b/app/Controller/Auth.php
@@ -39,7 +39,7 @@ class Auth extends Base
{
$values = $this->request->getValues();
$this->sessionStorage->hasRememberMe = ! empty($values['remember_me']);
- list($valid, $errors) = $this->authentication->validateForm($values);
+ list($valid, $errors) = $this->authValidator->validateForm($values);
if ($valid) {
$this->redirectAfterLogin();
diff --git a/app/Controller/Category.php b/app/Controller/Category.php
index 9864348c..a0af4139 100644
--- a/app/Controller/Category.php
+++ b/app/Controller/Category.php
@@ -57,7 +57,7 @@ class Category extends Base
$project = $this->getProject();
$values = $this->request->getValues();
- list($valid, $errors) = $this->category->validateCreation($values);
+ list($valid, $errors) = $this->categoryValidator->validateCreation($values);
if ($valid) {
if ($this->category->create($values)) {
@@ -99,7 +99,7 @@ class Category extends Base
$project = $this->getProject();
$values = $this->request->getValues();
- list($valid, $errors) = $this->category->validateModification($values);
+ list($valid, $errors) = $this->categoryValidator->validateModification($values);
if ($valid) {
if ($this->category->update($values)) {
diff --git a/app/Controller/Comment.php b/app/Controller/Comment.php
index 54339e48..a608dd1c 100644
--- a/app/Controller/Comment.php
+++ b/app/Controller/Comment.php
@@ -78,7 +78,7 @@ class Comment extends Base
$values = $this->request->getValues();
$ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax');
- list($valid, $errors) = $this->comment->validateCreation($values);
+ list($valid, $errors) = $this->commentValidator->validateCreation($values);
if ($valid) {
if ($this->comment->create($values)) {
@@ -127,7 +127,7 @@ class Comment extends Base
$comment = $this->getComment();
$values = $this->request->getValues();
- list($valid, $errors) = $this->comment->validateModification($values);
+ list($valid, $errors) = $this->commentValidator->validateModification($values);
if ($valid) {
if ($this->comment->update($values)) {
diff --git a/app/Controller/Currency.php b/app/Controller/Currency.php
index 4c5b8ee8..3d0deeac 100644
--- a/app/Controller/Currency.php
+++ b/app/Controller/Currency.php
@@ -51,7 +51,7 @@ class Currency extends Base
public function create()
{
$values = $this->request->getValues();
- list($valid, $errors) = $this->currency->validate($values);
+ list($valid, $errors) = $this->currencyValidator->validateCreation($values);
if ($valid) {
if ($this->currency->create($values['currency'], $values['rate'])) {
diff --git a/app/Controller/Customfilter.php b/app/Controller/Customfilter.php
index 12cc8e78..1b43f1d0 100644
--- a/app/Controller/Customfilter.php
+++ b/app/Controller/Customfilter.php
@@ -42,7 +42,7 @@ class Customfilter extends Base
$values = $this->request->getValues();
$values['user_id'] = $this->userSession->getId();
- list($valid, $errors) = $this->customFilter->validateCreation($values);
+ list($valid, $errors) = $this->customFilterValidator->validateCreation($values);
if ($valid) {
if ($this->customFilter->create($values)) {
@@ -121,7 +121,7 @@ class Customfilter extends Base
$values += array('append' => 0);
}
- list($valid, $errors) = $this->customFilter->validateModification($values);
+ list($valid, $errors) = $this->customFilterValidator->validateModification($values);
if ($valid) {
if ($this->customFilter->update($values)) {
diff --git a/app/Controller/Group.php b/app/Controller/Group.php
index 3c9c4a07..e952c0e5 100644
--- a/app/Controller/Group.php
+++ b/app/Controller/Group.php
@@ -79,7 +79,7 @@ class Group extends Base
public function save()
{
$values = $this->request->getValues();
- list($valid, $errors) = $this->group->validateCreation($values);
+ list($valid, $errors) = $this->groupValidator->validateCreation($values);
if ($valid) {
if ($this->group->create($values['name']) !== false) {
@@ -120,7 +120,7 @@ class Group extends Base
public function update()
{
$values = $this->request->getValues();
- list($valid, $errors) = $this->group->validateModification($values);
+ list($valid, $errors) = $this->groupValidator->validateModification($values);
if ($valid) {
if ($this->group->update($values) !== false) {
diff --git a/app/Controller/Link.php b/app/Controller/Link.php
index 2ae57b1a..d52d1f91 100644
--- a/app/Controller/Link.php
+++ b/app/Controller/Link.php
@@ -67,7 +67,7 @@ class Link extends Base
public function save()
{
$values = $this->request->getValues();
- list($valid, $errors) = $this->link->validateCreation($values);
+ list($valid, $errors) = $this->linkValidator->validateCreation($values);
if ($valid) {
if ($this->link->create($values['label'], $values['opposite_label']) !== false) {
@@ -108,7 +108,7 @@ class Link extends Base
public function update()
{
$values = $this->request->getValues();
- list($valid, $errors) = $this->link->validateModification($values);
+ list($valid, $errors) = $this->linkValidator->validateModification($values);
if ($valid) {
if ($this->link->update($values)) {
diff --git a/app/Core/Base.php b/app/Core/Base.php
index 22f09403..a3a30e60 100644
--- a/app/Core/Base.php
+++ b/app/Core/Base.php
@@ -54,7 +54,6 @@ use Pimple\Container;
* @property \Kanboard\Formatter\GroupAutoCompleteFormatter $groupAutoCompleteFormatter
* @property \Kanboard\Model\Action $action
* @property \Kanboard\Model\ActionParameter $actionParameter
- * @property \Kanboard\Model\Authentication $authentication
* @property \Kanboard\Model\Board $board
* @property \Kanboard\Model\Category $category
* @property \Kanboard\Model\Color $color
@@ -114,7 +113,15 @@ use Pimple\Container;
* @property \Kanboard\Model\UserMetadata $userMetadata
* @property \Kanboard\Model\Webhook $webhook
* @property \Kanboard\Validator\ActionValidator $actionValidator
+ * @property \Kanboard\Validator\AuthValidator $authValidator
* @property \Kanboard\Validator\ColumnValidator $columnValidator
+ * @property \Kanboard\Validator\CategoryValidator $categoryValidator
+ * @property \Kanboard\Validator\ColumnValidator $columnValidator
+ * @property \Kanboard\Validator\CommentValidator $commentValidator
+ * @property \Kanboard\Validator\CurrencyValidator $currencyValidator
+ * @property \Kanboard\Validator\CustomFilterValidator $customFilterValidator
+ * @property \Kanboard\Validator\GroupValidator $groupValidator
+ * @property \Kanboard\Validator\LinkValidator $linkValidator
* @property \Kanboard\Validator\PasswordResetValidator $passwordResetValidator
* @property \Kanboard\Validator\ProjectValidator $projectValidator
* @property \Kanboard\Validator\SubtaskValidator $subtaskValidator
diff --git a/app/Model/Category.php b/app/Model/Category.php
index bf40c60a..58cee738 100644
--- a/app/Model/Category.php
+++ b/app/Model/Category.php
@@ -2,9 +2,6 @@
namespace Kanboard\Model;
-use SimpleValidator\Validator;
-use SimpleValidator\Validators;
-
/**
* Category model
*
@@ -212,63 +209,4 @@ class Category extends Base
return true;
}
-
- /**
- * Validate category 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)
- {
- $rules = array(
- new Validators\Required('project_id', t('The project id is required')),
- new Validators\Required('name', t('The name is required')),
- );
-
- $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
-
- /**
- * Validate category 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)
- {
- $rules = array(
- new Validators\Required('id', t('The id is required')),
- new Validators\Required('name', t('The name is required')),
- );
-
- $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
-
- /**
- * Common validation rules
- *
- * @access private
- * @return array
- */
- private function commonValidationRules()
- {
- return array(
- new Validators\Integer('id', t('The id must be an integer')),
- new Validators\Integer('project_id', t('The project id must be an integer')),
- new Validators\MaxLength('name', t('The maximum length is %d characters', 50), 50)
- );
- }
}
diff --git a/app/Model/Comment.php b/app/Model/Comment.php
index eb83f8d6..6eb4a1e5 100644
--- a/app/Model/Comment.php
+++ b/app/Model/Comment.php
@@ -3,8 +3,6 @@
namespace Kanboard\Model;
use Kanboard\Event\CommentEvent;
-use SimpleValidator\Validator;
-use SimpleValidator\Validators;
/**
* Comment model
@@ -152,63 +150,4 @@ class Comment extends Base
{
return $this->db->table(self::TABLE)->eq('id', $comment_id)->remove();
}
-
- /**
- * Validate comment 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)
- {
- $rules = array(
- new Validators\Required('task_id', t('This value is required')),
- );
-
- $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
-
- /**
- * Validate comment modification
- *
- * @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 validateModification(array $values)
- {
- $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()
- );
- }
-
- /**
- * 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('task_id', t('This value must be an integer')),
- new Validators\Integer('user_id', t('This value must be an integer')),
- new Validators\MaxLength('reference', t('The maximum length is %d characters', 50), 50),
- new Validators\Required('comment', t('Comment is required'))
- );
- }
}
diff --git a/app/Model/Currency.php b/app/Model/Currency.php
index c1156610..316a0141 100644
--- a/app/Model/Currency.php
+++ b/app/Model/Currency.php
@@ -2,9 +2,6 @@
namespace Kanboard\Model;
-use SimpleValidator\Validator;
-use SimpleValidator\Validators;
-
/**
* Currency
*
@@ -83,24 +80,4 @@ class Currency extends Base
{
return $this->db->table(self::TABLE)->eq('currency', $currency)->update(array('rate' => $rate));
}
-
- /**
- * Validate
- *
- * @access public
- * @param array $values Form values
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validate(array $values)
- {
- $v = new Validator($values, array(
- new Validators\Required('currency', t('Field required')),
- new Validators\Required('rate', t('Field required')),
- ));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
}
diff --git a/app/Model/CustomFilter.php b/app/Model/CustomFilter.php
index 6550b4a7..3a6a1a3a 100644
--- a/app/Model/CustomFilter.php
+++ b/app/Model/CustomFilter.php
@@ -2,9 +2,6 @@
namespace Kanboard\Model;
-use SimpleValidator\Validator;
-use SimpleValidator\Validators;
-
/**
* Custom Filter model
*
@@ -102,63 +99,4 @@ class CustomFilter extends Base
{
return $this->db->table(self::TABLE)->eq('id', $filter_id)->remove();
}
-
- /**
- * Common validation rules
- *
- * @access private
- * @return array
- */
- private function commonValidationRules()
- {
- return array(
- new Validators\Required('project_id', t('Field required')),
- new Validators\Required('user_id', t('Field required')),
- new Validators\Required('name', t('Field required')),
- new Validators\Required('filter', t('Field required')),
- new Validators\Integer('user_id', t('This value must be an integer')),
- new Validators\Integer('project_id', t('This value must be an integer')),
- new Validators\MaxLength('name', t('The maximum length is %d characters', 100), 100),
- new Validators\MaxLength('filter', t('The maximum length is %d characters', 100), 100)
- );
- }
-
- /**
- * Validate filter 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)
- {
- $v = new Validator($values, $this->commonValidationRules());
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
-
- /**
- * Validate filter 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)
- {
- $rules = array(
- new Validators\Required('id', t('Field required')),
- new Validators\Integer('id', t('This value must be an integer')),
- );
-
- $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
}
diff --git a/app/Model/Group.php b/app/Model/Group.php
index a086fe9d..ce8c0284 100644
--- a/app/Model/Group.php
+++ b/app/Model/Group.php
@@ -117,59 +117,4 @@ class Group extends Base
{
return $this->db->table(self::TABLE)->eq('id', $values['id'])->update($values);
}
-
- /**
- * Validate 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)
- {
- $v = new Validator($values, $this->commonValidationRules());
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
-
- /**
- * Validate 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)
- {
- $rules = array(
- new Validators\Required('id', t('The id is required')),
- );
-
- $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
-
- /**
- * Common validation rules
- *
- * @access private
- * @return array
- */
- private function commonValidationRules()
- {
- return array(
- new Validators\Required('name', t('The name is required')),
- new Validators\MaxLength('name', t('The maximum length is %d characters', 100), 100),
- new Validators\Unique('name', t('The name must be unique'), $this->db->getConnection(), self::TABLE, 'id'),
- new Validators\MaxLength('external_id', t('The maximum length is %d characters', 255), 255),
- new Validators\Integer('id', t('This value must be an integer')),
- );
- }
}
diff --git a/app/Model/Link.php b/app/Model/Link.php
index 00b6dfc5..7b81a237 100644
--- a/app/Model/Link.php
+++ b/app/Model/Link.php
@@ -3,8 +3,6 @@
namespace Kanboard\Model;
use PDO;
-use SimpleValidator\Validator;
-use SimpleValidator\Validators;
/**
* Link model
@@ -176,47 +174,4 @@ class Link extends Base
$this->db->table(self::TABLE)->eq('opposite_id', $link_id)->update(array('opposite_id' => 0));
return $this->db->table(self::TABLE)->eq('id', $link_id)->remove();
}
-
- /**
- * Validate 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)
- {
- $v = new Validator($values, array(
- new Validators\Required('label', t('Field required')),
- new Validators\Unique('label', t('This label must be unique'), $this->db->getConnection(), self::TABLE),
- new Validators\NotEquals('label', 'opposite_label', t('The labels must be different')),
- ));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
-
- /**
- * Validate 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)
- {
- $v = new Validator($values, array(
- new Validators\Required('id', t('Field required')),
- new Validators\Required('opposite_id', t('Field required')),
- new Validators\Required('label', t('Field required')),
- new Validators\Unique('label', t('This label must be unique'), $this->db->getConnection(), self::TABLE),
- ));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
}
diff --git a/app/ServiceProvider/ClassProvider.php b/app/ServiceProvider/ClassProvider.php
index 61c97a07..a0f8901a 100644
--- a/app/ServiceProvider/ClassProvider.php
+++ b/app/ServiceProvider/ClassProvider.php
@@ -17,7 +17,6 @@ class ClassProvider implements ServiceProviderInterface
'Model' => array(
'Action',
'ActionParameter',
- 'Authentication',
'Board',
'Category',
'Color',
@@ -86,7 +85,14 @@ class ClassProvider implements ServiceProviderInterface
),
'Validator' => array(
'ActionValidator',
+ 'AuthValidator',
+ 'CategoryValidator',
'ColumnValidator',
+ 'CommentValidator',
+ 'CurrencyValidator',
+ 'CustomFilterValidator',
+ 'GroupValidator',
+ 'LinkValidator',
'PasswordResetValidator',
'ProjectValidator',
'SubtaskValidator',
diff --git a/app/Model/Authentication.php b/app/Validator/AuthValidator.php
index d10f2bf8..e77a88c8 100644
--- a/app/Model/Authentication.php
+++ b/app/Validator/AuthValidator.php
@@ -1,18 +1,18 @@
<?php
-namespace Kanboard\Model;
+namespace Kanboard\Validator;
use SimpleValidator\Validator;
use SimpleValidator\Validators;
use Gregwar\Captcha\CaptchaBuilder;
/**
- * Authentication model
+ * Authentication Validator
*
- * @package model
+ * @package validator
* @author Frederic Guillot
*/
-class Authentication extends Base
+class AuthValidator extends Base
{
/**
* Validate user login form
diff --git a/app/Validator/CategoryValidator.php b/app/Validator/CategoryValidator.php
new file mode 100644
index 00000000..715aed66
--- /dev/null
+++ b/app/Validator/CategoryValidator.php
@@ -0,0 +1,74 @@
+<?php
+
+namespace Kanboard\Validator;
+
+use SimpleValidator\Validator;
+use SimpleValidator\Validators;
+
+/**
+ * Category Validator
+ *
+ * @package validator
+ * @author Frederic Guillot
+ */
+class CategoryValidator extends Base
+{
+ /**
+ * Validate category 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)
+ {
+ $rules = array(
+ new Validators\Required('project_id', t('The project id is required')),
+ new Validators\Required('name', t('The name is required')),
+ );
+
+ $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
+
+ return array(
+ $v->execute(),
+ $v->getErrors()
+ );
+ }
+
+ /**
+ * Validate category 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)
+ {
+ $rules = array(
+ new Validators\Required('id', t('The id is required')),
+ new Validators\Required('name', t('The name is required')),
+ );
+
+ $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
+
+ return array(
+ $v->execute(),
+ $v->getErrors()
+ );
+ }
+
+ /**
+ * Common validation rules
+ *
+ * @access private
+ * @return array
+ */
+ private function commonValidationRules()
+ {
+ return array(
+ new Validators\Integer('id', t('The id must be an integer')),
+ new Validators\Integer('project_id', t('The project id must be an integer')),
+ new Validators\MaxLength('name', t('The maximum length is %d characters', 50), 50)
+ );
+ }
+}
diff --git a/app/Validator/CommentValidator.php b/app/Validator/CommentValidator.php
new file mode 100644
index 00000000..4eb54206
--- /dev/null
+++ b/app/Validator/CommentValidator.php
@@ -0,0 +1,74 @@
+<?php
+
+namespace Kanboard\Validator;
+
+use SimpleValidator\Validator;
+use SimpleValidator\Validators;
+
+/**
+ * Comment Validator
+ *
+ * @package validator
+ * @author Frederic Guillot
+ */
+class CommentValidator extends Base
+{
+ /**
+ * Validate comment 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)
+ {
+ $rules = array(
+ new Validators\Required('task_id', t('This value is required')),
+ );
+
+ $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
+
+ return array(
+ $v->execute(),
+ $v->getErrors()
+ );
+ }
+
+ /**
+ * Validate comment modification
+ *
+ * @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 validateModification(array $values)
+ {
+ $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()
+ );
+ }
+
+ /**
+ * 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('task_id', t('This value must be an integer')),
+ new Validators\Integer('user_id', t('This value must be an integer')),
+ new Validators\MaxLength('reference', t('The maximum length is %d characters', 50), 50),
+ new Validators\Required('comment', t('Comment is required'))
+ );
+ }
+}
diff --git a/app/Validator/CurrencyValidator.php b/app/Validator/CurrencyValidator.php
new file mode 100644
index 00000000..a00af738
--- /dev/null
+++ b/app/Validator/CurrencyValidator.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Kanboard\Validator;
+
+use SimpleValidator\Validator;
+use SimpleValidator\Validators;
+
+/**
+ * Currency Validator
+ *
+ * @package validator
+ * @author Frederic Guillot
+ */
+class CurrencyValidator extends Base
+{
+ /**
+ * Validate
+ *
+ * @access public
+ * @param array $values Form values
+ * @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('currency', t('Field required')),
+ new Validators\Required('rate', t('Field required')),
+ ));
+
+ return array(
+ $v->execute(),
+ $v->getErrors()
+ );
+ }
+}
diff --git a/app/Validator/CustomFilterValidator.php b/app/Validator/CustomFilterValidator.php
new file mode 100644
index 00000000..07f2a1eb
--- /dev/null
+++ b/app/Validator/CustomFilterValidator.php
@@ -0,0 +1,74 @@
+<?php
+
+namespace Kanboard\Validator;
+
+use SimpleValidator\Validator;
+use SimpleValidator\Validators;
+
+/**
+ * Custom Filter Validator
+ *
+ * @package validator
+ * @author Frederic Guillot
+ */
+class CustomFilterValidator extends Base
+{
+ /**
+ * Common validation rules
+ *
+ * @access private
+ * @return array
+ */
+ private function commonValidationRules()
+ {
+ return array(
+ new Validators\Required('project_id', t('Field required')),
+ new Validators\Required('user_id', t('Field required')),
+ new Validators\Required('name', t('Field required')),
+ new Validators\Required('filter', t('Field required')),
+ new Validators\Integer('user_id', t('This value must be an integer')),
+ new Validators\Integer('project_id', t('This value must be an integer')),
+ new Validators\MaxLength('name', t('The maximum length is %d characters', 100), 100),
+ new Validators\MaxLength('filter', t('The maximum length is %d characters', 100), 100)
+ );
+ }
+
+ /**
+ * Validate filter 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)
+ {
+ $v = new Validator($values, $this->commonValidationRules());
+
+ return array(
+ $v->execute(),
+ $v->getErrors()
+ );
+ }
+
+ /**
+ * Validate filter 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)
+ {
+ $rules = array(
+ new Validators\Required('id', t('Field required')),
+ new Validators\Integer('id', t('This value must be an integer')),
+ );
+
+ $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
+
+ return array(
+ $v->execute(),
+ $v->getErrors()
+ );
+ }
+}
diff --git a/app/Validator/GroupValidator.php b/app/Validator/GroupValidator.php
new file mode 100644
index 00000000..2226abd3
--- /dev/null
+++ b/app/Validator/GroupValidator.php
@@ -0,0 +1,71 @@
+<?php
+
+namespace Kanboard\Validator;
+
+use SimpleValidator\Validator;
+use SimpleValidator\Validators;
+use Kanboard\Model\Group;
+
+/**
+ * Group Validator
+ *
+ * @package validator
+ * @author Frederic Guillot
+ */
+class GroupValidator extends Base
+{
+ /**
+ * Validate 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)
+ {
+ $v = new Validator($values, $this->commonValidationRules());
+
+ return array(
+ $v->execute(),
+ $v->getErrors()
+ );
+ }
+
+ /**
+ * Validate 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)
+ {
+ $rules = array(
+ new Validators\Required('id', t('The id is required')),
+ );
+
+ $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
+
+ return array(
+ $v->execute(),
+ $v->getErrors()
+ );
+ }
+
+ /**
+ * Common validation rules
+ *
+ * @access private
+ * @return array
+ */
+ private function commonValidationRules()
+ {
+ return array(
+ new Validators\Required('name', t('The name is required')),
+ new Validators\MaxLength('name', t('The maximum length is %d characters', 100), 100),
+ new Validators\Unique('name', t('The name must be unique'), $this->db->getConnection(), Group::TABLE, 'id'),
+ new Validators\MaxLength('external_id', t('The maximum length is %d characters', 255), 255),
+ new Validators\Integer('id', t('This value must be an integer')),
+ );
+ }
+}
diff --git a/app/Validator/LinkValidator.php b/app/Validator/LinkValidator.php
new file mode 100644
index 00000000..10a826da
--- /dev/null
+++ b/app/Validator/LinkValidator.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace Kanboard\Validator;
+
+use SimpleValidator\Validator;
+use SimpleValidator\Validators;
+use Kanboard\Model\Link;
+
+/**
+ * Link Validator
+ *
+ * @package validator
+ * @author Frederic Guillot
+ */
+class LinkValidator extends Base
+{
+ /**
+ * Validate 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)
+ {
+ $v = new Validator($values, array(
+ new Validators\Required('label', t('Field required')),
+ new Validators\Unique('label', t('This label must be unique'), $this->db->getConnection(), Link::TABLE),
+ new Validators\NotEquals('label', 'opposite_label', t('The labels must be different')),
+ ));
+
+ return array(
+ $v->execute(),
+ $v->getErrors()
+ );
+ }
+
+ /**
+ * Validate 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)
+ {
+ $v = new Validator($values, array(
+ new Validators\Required('id', t('Field required')),
+ new Validators\Required('opposite_id', t('Field required')),
+ new Validators\Required('label', t('Field required')),
+ new Validators\Unique('label', t('This label must be unique'), $this->db->getConnection(), Link::TABLE),
+ ));
+
+ return array(
+ $v->execute(),
+ $v->getErrors()
+ );
+ }
+}