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.

29 lines
728 B

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