Source for file Validator.php

Documentation is available at Validator.php

  1. <?php
  2.  
  3. /**
  4. * MVCnPHP - Validator.class.php
  5. *
  6. * This source file is subject to version 2.02 of the PHP license,
  7. * that is bundled with this package in the file LICENSE, and is
  8. * available at through the world-wide-web at
  9. * http://www.php.net/license/2_02.txt.
  10. * If you did not receive a copy of the PHP license and are unable to
  11. * obtain it through the world-wide-web, please send a note to
  12. * license@php.net so we can mail you a copy immediately.
  13. *
  14. * @author Tony Bibbs <tony@geeklog.net>
  15. * @copyright Tony Bibbs 2003
  16. * @package net.geeklog.mvc
  17. * @version $Id: Validator.class.php,v 1.3 2003/08/28 01:31:22 tony Exp $
  18. *
  19. */
  20.  
  21. /**
  22. * MVC base command object
  23. */
  24. require_once 'BaseCommand.php';
  25.  
  26. /**
  27. * MVC form object
  28. */
  29. require_once 'Form.php';
  30.  
  31. /**
  32. * This is a validator class meant to ease the tasks
  33. * often done by validation logic
  34. *
  35. * @author Tony Bibbs <tony@geeklog.net>
  36. * @package net.geeklog.mvc
  37. *
  38. */
  39. class MVCnPHP_Validator extends MVCnPHP_BaseCommand {
  40. /**
  41. * @access private
  42. * @var object
  43. */
  44. private $form = null;
  45. /**
  46. * Constructor
  47. *
  48. * Initializes form object
  49. *
  50. * @author Tony Bibbs <tony@geeklog.net>
  51. * @access public
  52. *
  53. */
  54. public function __construct()
  55. {
  56. $this->_form = new MVCnPHP_Form($_REQUEST);
  57. }
  58. /**
  59. * Determines if the submitted form has a value for a given
  60. * variable name
  61. *
  62. * This is a simple pass thru to the form object
  63. *
  64. * @author Tony Bibbs <tony@geeklog.net>
  65. * @access public
  66. * @param string $varName Name of form variable
  67. * @return boolean True if found, otherwise false
  68. *
  69. */
  70. public function contains($varName)
  71. {
  72. return $this->_form->contains($varName);
  73. }
  74. /**
  75. * Gets value for given variable name
  76. *
  77. * This is a simple pass thru to the form object
  78. *
  79. * @author Tony Bibbs <tony@geeklog.net>
  80. * @access public
  81. * @param string $varName Name of form variable to get value for
  82. * @return variant Value of form variable
  83. *
  84. */
  85. public function get($varName)
  86. {
  87. return $this->_form->get($varName);
  88. }
  89. /**
  90. * Deletes a form variable
  91. *
  92. * This is a simple pass thru to the form object
  93. *
  94. * @author Tony Bibbs <tony@geeklog.net>
  95. * @access public
  96. * @param string $varName Name of form variable to delete
  97. *
  98. */
  99. public function remove($varName)
  100. {
  101. $this->_form->remove($varName);
  102. }
  103. /**
  104. * Sets a field to given value
  105. *
  106. * This is a simple pass thru to the form object
  107. *
  108. * @author Tony Bibbs <tony@geeklog.net>
  109. * @access public
  110. * @param string $varName Name of field to set
  111. * @param string $value Value to set field to
  112. *
  113. */
  114. public function set($varName, $value)
  115. {
  116. $this->_form->set($varName, $value);
  117. }
  118. /**
  119. * Returns value array
  120. *
  121. * This is a simple pass thru to the form object
  122. *
  123. * @author Tony Bibbs <tony@geeklog.net>
  124. * @access public
  125. * @return array Values array
  126. *
  127. */
  128. public function &getValues()
  129. {
  130. return $this->_form->getValues();
  131. }
  132. }
  133.  
  134. ?>

Documentation generated on Mon, 7 Mar 2005 22:36:22 -0600 by phpDocumentor 1.3.0RC3