Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationMain
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cValidatorAbstract
  • cValidatorEmail
  • cValidatorFactory
  • cValidatorRegex
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
 1: <?php
 2: /**
 3:  * This file contains the abstract validator class.
 4:  *
 5:  * @package    Core
 6:  * @subpackage Validation
 7:  * @version    SVN Revision $Rev:$
 8:  *
 9:  * @author     Murat Purc <murat@purc.de>
10:  * @copyright  four for business AG <www.4fb.de>
11:  * @license    http://www.contenido.org/license/LIZENZ.txt
12:  * @link       http://www.4fb.de
13:  * @link       http://www.contenido.org
14:  */
15: 
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17: 
18: /**
19:  * Abstract validator.
20:  *
21:  * @package    Core
22:  * @subpackage Validation
23:  */
24: abstract class cValidatorAbstract {
25: 
26:     /**
27:      * List of options, depends by used validator
28:      * @var array
29:      */
30:     protected $_options = array();
31: 
32:     /**
33:      * List of validations errors
34:      * @var array
35:      */
36:     protected $_errors = array();
37: 
38:     /**
39:      * Options setter, merges passed options with previous set options.
40:      * @param  array  $options
41:      */
42:     public function setOptions(array $options) {
43:         $this->_options = array_merge($this->_options, $options);
44:     }
45: 
46:     /**
47:      * Single option setter.
48:      * @param  string  $name
49:      * @param  mixed   $value
50:      */
51:     public function setOption($name, $value) {
52:         $this->_options[$name] = $value;
53:     }
54: 
55:     /**
56:      * Option getter.
57:      * @param   string  $name
58:      * @return  mixed|null
59:      */
60:     public function getOption($name) {
61:         return isset($this->_options[$name]) ? $this->_options[$name] : null;
62:     }
63: 
64:     /**
65:      * Returns list of validations errors
66:      * @return  array
67:      */
68:     public function getErrors() {
69:         return $this->_errors;
70:     }
71: 
72:     /**
73:      * Adds a error.
74:      * @param  string  $message
75:      * @param  mixed   $code
76:      */
77:     protected function addError($message, $code) {
78:         $this->_errors[] = (object) array('message' => $message, 'code' => $code);
79:     }
80: 
81:     /**
82:      * Validates the passed value.
83:      *
84:      * @param   mixed  $value
85:      * @return  bool
86:      */
87:     public function isValid($value) {
88:         return $this->_isValid($value);
89:     }
90: 
91:     /**
92:      * Abstract isValid method, which has to be implemented by childs
93:      *
94:      * @param   mixed  $value
95:      * @return  bool
96:      */
97:     abstract protected function _isValid($value);
98: }
99: 
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0