Validator, captcha, form, #16
git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@141 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
32
validator/NotEmptyValidator.php
Normal file
32
validator/NotEmptyValidator.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
* @package Majestic
|
||||
* @subpackage validator
|
||||
* @since 2010-04-26
|
||||
* @version SVN: $Id$
|
||||
* @filesource $URL$
|
||||
*/
|
||||
|
||||
class NotEmptyValidator extends 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