Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • 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: /**
  4:  * This file contains the abstract validator class.
  5:  *
  6:  * @package    Core
  7:  * @subpackage Validation
  8:  * @author     Murat Purc <murat@purc.de>
  9:  * @copyright  four for business AG <www.4fb.de>
 10:  * @license    http://www.contenido.org/license/LIZENZ.txt
 11:  * @link       http://www.4fb.de
 12:  * @link       http://www.contenido.org
 13:  */
 14: 
 15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 16: 
 17: /**
 18:  * Abstract validator.
 19:  *
 20:  * @package    Core
 21:  * @subpackage Validation
 22:  */
 23: abstract class cValidatorAbstract {
 24: 
 25:     /**
 26:      * List of options, depends by used validator
 27:      *
 28:      * @var array
 29:      */
 30:     protected $_options = array();
 31: 
 32:     /**
 33:      * List of validations errors
 34:      *
 35:      * @var array
 36:      */
 37:     protected $_errors = array();
 38: 
 39:     /**
 40:      * Options setter, merges passed options with previous set options.
 41:      *
 42:      * @param array $options
 43:      */
 44:     public function setOptions(array $options) {
 45:         $this->_options = array_merge($this->_options, $options);
 46:     }
 47: 
 48:     /**
 49:      * Single option setter.
 50:      *
 51:      * @param string $name
 52:      * @param mixed $value
 53:      */
 54:     public function setOption($name, $value) {
 55:         $this->_options[$name] = $value;
 56:     }
 57: 
 58:     /**
 59:      * Option getter.
 60:      *
 61:      * @param string $name
 62:      * @return mixed|NULL
 63:      */
 64:     public function getOption($name) {
 65:         return isset($this->_options[$name]) ? $this->_options[$name] : NULL;
 66:     }
 67: 
 68:     /**
 69:      * Returns list of validations errors
 70:      *
 71:      * @return array
 72:      */
 73:     public function getErrors() {
 74:         return $this->_errors;
 75:     }
 76: 
 77:     /**
 78:      * Adds a error.
 79:      *
 80:      * @param string $message
 81:      * @param mixed $code
 82:      */
 83:     protected function addError($message, $code) {
 84:         $this->_errors[] = (object) array('message' => $message, 'code' => $code);
 85:     }
 86: 
 87:     /**
 88:      * Validates the passed value.
 89:      *
 90:      * @param mixed $value
 91:      * @return bool
 92:      */
 93:     public function isValid($value) {
 94:         return $this->_isValid($value);
 95:     }
 96: 
 97:     /**
 98:      * Abstract isValid method, which has to be implemented by childs
 99:      *
100:      * @param mixed $value
101:      * @return bool
102:      */
103:     abstract protected function _isValid($value);
104: }
105: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0