propel-validator
[ class tree: propel-validator ] [ index: propel-validator ] [ all elements ]

Source for file ValidationFailed.php

Documentation is available at ValidationFailed.php

  1. <?php
  2. /*
  3.  *  $Id: ValidationFailed.php 521 2007-01-05 13:29:36Z heltem $
  4.  *
  5.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  6.  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8.  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9.  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15.  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16.  *
  17.  * This software consists of voluntary contributions made by many individuals
  18.  * and is licensed under the LGPL. For more information please see
  19.  * <http://propel.phpdb.org>.
  20.  */
  21.  
  22.  
  23. /**
  24.  * Simple class that serves as a container for any information about a failed validation.
  25.  *
  26.  * Currently this class stores the qualified column name (e.g. tablename.COLUMN_NAME) and
  27.  * the message that should be displayed to the user.
  28.  *
  29.  * An array of these objects will be returned by BasePeer::doValidate() if validation
  30.  * failed.
  31.  *
  32.  * @author     Hans Lellelid <hans@xmpl.org>
  33.  * @version    $Revision: 521 $
  34.  * @package    propel.validator
  35.  * @see        BasePeer::doValidate()
  36.  */
  37.  
  38.     /** Column name in tablename.COLUMN_NAME format */
  39.     private $colname;
  40.  
  41.     /** Message to display to user. */
  42.     private $message;
  43.  
  44.     /** Validator object that caused this to fail. */
  45.     private $validator;
  46.  
  47.     /**
  48.      * Construct a new ValidationFailed object.
  49.      * @param      string $colname Column name.
  50.      * @param      string $message Message to display to user.
  51.      * @param      object $validator The Validator that caused this column to fail.
  52.      */
  53.     public function __construct($colname$message$validator null)
  54.     {
  55.         $this->colname $colname;
  56.         $this->message $message;
  57.         $this->validator $validator;
  58.     }
  59.  
  60.     /**
  61.      * Set the column name.
  62.      * @param      string $v 
  63.      */
  64.     public function setColumn($v)
  65.     {
  66.         $this->colname $v;
  67.     }
  68.  
  69.     /**
  70.      * Gets the column name.
  71.      * @return     string Qualified column name (tablename.COLUMN_NAME)
  72.      */
  73.     public function getColumn()
  74.     {
  75.         return $this->colname;
  76.     }
  77.  
  78.     /**
  79.      * Set the message for the validation failure.
  80.      * @param      string $v 
  81.      */
  82.     public function setMessage($v)
  83.     {
  84.         $this->message $v;
  85.     }
  86.  
  87.     /**
  88.      * Gets the message for the validation failure.
  89.      * @return     string 
  90.      */
  91.     public function getMessage()
  92.     {
  93.         return $this->message;
  94.     }
  95.  
  96.     /**
  97.      * Set the validator object that caused this to fail.
  98.      * @param      object $v 
  99.      */
  100.     public function setValidator($v)
  101.     {
  102.         $this->validator $v;
  103.     }
  104.  
  105.     /**
  106.      * Gets the validator object that caused this to fail.
  107.      * @return     object 
  108.      */
  109.     public function getValidator()
  110.     {
  111.         return $this->validator;
  112.     }
  113.  
  114.     /**
  115.      * "magic" method to get string represenation of object.
  116.      * Maybe someday PHP5 will support the invoking this method automatically
  117.      * on (string) cast.  Until then it's pretty useless.
  118.      * @return     string 
  119.      */
  120.     public function __toString()
  121.     {
  122.         return $this->getMessage();
  123.     }
  124.  
  125. }

Documentation generated on Thu, 22 Nov 2007 03:33:56 +0000 by phpDocumentor 1.4.0