NoHtml.php 873 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. *
  4. * Cube Framework $Id$ mnxBdyl7M4S5UMTZdQSekcygQYITr/LPxXBqke2+axk=
  5. *
  6. * @link http://codecu.be/framework
  7. * @copyright Copyright (c) 2017 CodeCube SRL
  8. * @license http://codecu.be/framework/license Commercial License
  9. *
  10. * @version 1.10 [rev.1.10.01]
  11. */
  12. /**
  13. * no html validator class
  14. */
  15. namespace Cube\Validate;
  16. class NoHtml extends AbstractValidate
  17. {
  18. protected $_message = "'%s' cannot contain any html code.";
  19. /**
  20. *
  21. * checks if the variable contains only text (no html)
  22. *
  23. * @return bool return true if the validation is successful
  24. */
  25. public function isValid()
  26. {
  27. $value = $this->getValue();
  28. if (empty($value)) {
  29. return true;
  30. }
  31. if ($value != strip_tags($value)) {
  32. return false;
  33. }
  34. return true;
  35. }
  36. }