You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
731 B

  1. <?php
  2. /**
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage validator
  7. * @since 2010-04-26
  8. * @version SVN: $Id$
  9. * @filesource $URL$
  10. */
  11. class NotEmptyValidator extends Validator
  12. {
  13. const IS_EMPTY = 'is_empty';
  14. protected $templates = array(self::IS_EMPTY => 'Value is required and can\'t be empty');
  15. public function isValid($value, $context = null)
  16. {
  17. $this->setValue($value);
  18. if (is_string($value) && $value === '') {
  19. $this->error();
  20. return false;
  21. } elseif (!is_string($value) && empty($value)) {
  22. $this->error();
  23. return false;
  24. }
  25. return true;
  26. }
  27. }