summaryrefslogtreecommitdiffstats
path: root/library/Poolctrl/Validator/TitleUnique.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/Poolctrl/Validator/TitleUnique.php')
-rwxr-xr-xlibrary/Poolctrl/Validator/TitleUnique.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/library/Poolctrl/Validator/TitleUnique.php b/library/Poolctrl/Validator/TitleUnique.php
new file mode 100755
index 0000000..e935736
--- /dev/null
+++ b/library/Poolctrl/Validator/TitleUnique.php
@@ -0,0 +1,25 @@
+<?php
+require_once 'Zend/Validate/Abstract.php';
+
+class Poolctrl_Validate_TitleUnique extends Zend_Validate_Abstract
+{
+ const NOT_UNIQUE = 'notUnique';
+
+ protected $_messageTemplates = array(
+ self::NOT_UNIQUE => "Title is already assigned",
+ );
+
+ public function isValid($value)
+ {
+ $this->_setValue($value);
+ $eventMapper = new Application_Model_EventMapper();
+ $sameEvent = $eventMapper->findBy(array("title" => $value));
+
+ if (count($sameEvent) > 0) {
+ $this->_error(self::NOT_UNIQUE);
+ return false;
+ } else {
+ return true;
+ }
+ }
+} \ No newline at end of file