Structures_Form
[ class tree: Structures_Form ] [ index: Structures_Form ] [ all elements ]

Source for file RuleInterface.php

Documentation is available at RuleInterface.php

  1. <?php
  2. /**
  3.  * An interface to enforce consistency among all group elements used in a
  4.  * Structures_Form.
  5.  *
  6.  * In HTML_QuickForm, all form rules extend a base rule class. While this is
  7.  * technically possible for Structures_Form, it prevents any other class from
  8.  * being extended to create a rule class. For example, an XML validation rule
  9.  * may be needed. Instead of wrapping some other XML class, a Structures_Form
  10.  * rule can extend that class and maintain the same API without the need for
  11.  * lots of developer work.
  12.  *
  13.  * The constructor for the rule should define all the needed arguments. It is
  14.  * not possible to define the constructor here because the number of arguments
  15.  * may vary depending on what the rule needs.
  16.  *
  17.  * This interface defines method needed to validate values.
  18.  *
  19.  * A note contributors: I welcome contributions from others but I will not
  20.  * include any classes in the package that are not accompanied by a complete
  21.  * set of PHPUnit2 unit tests. Also, I am a stickler for documentation. Please
  22.  * make sure that your contributions are fully documented. Docblocks are not
  23.  * enough. There must be inline documentation. Please see Structures/Form.php
  24.  * for an example of what I mean by fully documented. Plus as you can see the
  25.  * interface is very simple.
  26.  *
  27.  * @author    Scott Mattocks
  28.  * @package   Structures_Form
  29.  * @license   PHP License
  30.  * @version   0.8.0devel
  31.  * @copyright Copyright 2006 Scott Mattocks
  32.  */
  33.  
  34.     /**
  35.      * Validates a value against the rule.
  36.      *
  37.      * If the value is not valid according to the rule, this method should
  38.      * return an error message. It is up to the rule to make sure the message
  39.      * is meaningful.
  40.      *
  41.      * @access public
  42.      * @param  object $element The form element.
  43.      * @return mixed  true if the value is ok, an error message otherwise.
  44.      */
  45.     public function validate(Structures_Form_ElementInterface $element);
  46. }
  47. ?>

Documentation generated on Mon, 11 Mar 2019 14:44:13 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.