Add namespace.
This commit is contained in:
30
Validator/NotEmptyValidator.php
Normal file
30
Validator/NotEmptyValidator.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php namespace Majestic\Validator;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
* @package Majestic
|
||||
* @subpackage validator
|
||||
* @since 2010-04-26
|
||||
*/
|
||||
|
||||
class NotEmptyValidator extends \Majestic\Validator
|
||||
{
|
||||
|
||||
const IS_EMPTY = 'is_empty';
|
||||
|
||||
protected $templates = array(self::IS_EMPTY => 'Value is required and can\'t be empty');
|
||||
|
||||
public function isValid($value, $context = null)
|
||||
{
|
||||
$this->setValue($value);
|
||||
|
||||
if (is_string($value) && $value === '') {
|
||||
$this->error();
|
||||
return false;
|
||||
} elseif (!is_string($value) && empty($value)) {
|
||||
$this->error();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user