MinText.php 733 B

12345678910111213141516171819202122232425
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * QuickForm rule to check a text field has a minimum of X chars
  5. * @package chamilo.include
  6. */
  7. class Html_Quickform_Rule_MinText extends HTML_QuickForm_Rule
  8. {
  9. /**
  10. * Function to check a text field has a minimum of X chars
  11. * @see HTML_QuickForm_Rule
  12. * @param string $text A text
  13. * @param int $count The minimum number of characters that the text should contain
  14. * @return boolean True if text has the minimum number of chars required
  15. */
  16. public function validate($text, $count)
  17. {
  18. $checkMinText = function($a, $b) {
  19. return strlen(utf8_decode($a)) >= $b;
  20. };
  21. return $checkMinText($text, $count);
  22. }
  23. }