Changeset 1033

Show
Ignore:
Timestamp:
11/12/07 16:51:23 (1 year ago)
Author:
richi
Message:

added support for individual (request) value error ids

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/ipo/request/filters/stubAbstractStringFilter.php

    r1012 r1033  
    4747     */ 
    4848    protected $encoderMode = stubStringEncoder::MODE_DECODE; 
     49    /** 
     50     * default value for empty field  
     51     * 
     52     * @var  string 
     53     */ 
     54    protected $emptyErrorId = 'FIELD_EMPTY'; 
    4955 
     56    /** 
     57     * set a min length validator 
     58     * 
     59     * @param  stubValidator  $minLength 
     60     */ 
     61    public function setEmptyErrorId($errorId) 
     62    { 
     63        $this->emptyErrorId = $errorId; 
     64    } 
     65     
    5066    /** 
    5167     * set a min length validator 
     
    133149        // if input length is zero but input is required 
    134150        if ((null == $value || strlen($value) == 0) && true == $this->isRequired) { 
    135             throw new stubFilterException($this->rveFactory->create('FIELD_EMPTY')); 
     151            throw new stubFilterException($this->rveFactory->create($this->emptyErrorId)); 
    136152        // if input is shorter than maximal allowed length 
    137153        } elseif (null != $this->minLength && $this->minLength->validate($value) == false) { 
  • trunk/src/main/php/net/stubbles/ipo/request/filters/stubStringFilter.php

    r731 r1033  
    2626     */ 
    2727    protected $regex; 
     28    /** 
     29     * wrong value error id 
     30     * 
     31     * @var  stubValidator 
     32     */ 
     33    protected $wrongValueErrorId; 
    2834 
    2935    /** 
     
    3339     * @param  stubValidator                 $regex       validator to use for checking the string 
    3440     */ 
    35     public function __construct(stubRequestValueErrorFactory $rveFactory, stubValidator $regex
     41    public function __construct(stubRequestValueErrorFactory $rveFactory, stubValidator $regex, $wrongValueErrorId = 'FIELD_WRONG_VALUE'
    3642    { 
    37         $this->rveFactory = $rveFactory; 
    38         $this->regex      = $regex; 
     43        $this->rveFactory         = $rveFactory; 
     44        $this->regex              = $regex; 
     45        $this->wrongValueErrorId  = $wrongValueErrorId;  
    3946    } 
    4047 
     
    6471 
    6572            if ($this->regex->validate($value) == false) { 
    66                 throw new stubFilterException($this->rveFactory->create('FIELD_WRONG_VALUE')); 
     73                throw new stubFilterException($this->rveFactory->create($this->wrongValueErrorId)); 
    6774            } 
    6875        }