2010-06-24 09:40:05 +01:00
|
|
|
<?php
|
|
|
|
|
2010-10-02 11:42:31 +01:00
|
|
|
/*
|
2011-01-15 13:29:43 +00:00
|
|
|
* This file is part of the Symfony package.
|
2010-10-02 11:42:31 +01:00
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2010-10-02 11:42:31 +01:00
|
|
|
*
|
2011-01-15 13:29:43 +00:00
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
2010-10-02 11:42:31 +01:00
|
|
|
*/
|
|
|
|
|
2011-01-15 13:29:43 +00:00
|
|
|
namespace Symfony\Component\Validator\Constraints;
|
|
|
|
|
2010-08-20 22:09:55 +01:00
|
|
|
use Symfony\Component\Validator\Constraint;
|
|
|
|
use Symfony\Component\Validator\ConstraintValidator;
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2011-07-20 09:37:57 +01:00
|
|
|
/**
|
|
|
|
* @api
|
|
|
|
*/
|
2010-06-24 09:40:05 +01:00
|
|
|
class NotBlankValidator extends ConstraintValidator
|
|
|
|
{
|
2011-07-20 09:37:57 +01:00
|
|
|
/**
|
|
|
|
* Checks if the passed value is valid.
|
|
|
|
*
|
|
|
|
* @param mixed $value The value that should be validated
|
2011-08-10 15:11:31 +01:00
|
|
|
* @param Constraint $constraint The constraint for the validation
|
2011-07-20 09:37:57 +01:00
|
|
|
*
|
|
|
|
* @return Boolean Whether or not the value is valid
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
2010-06-24 10:24:08 +01:00
|
|
|
public function isValid($value, Constraint $constraint)
|
2010-06-24 09:40:05 +01:00
|
|
|
{
|
2011-08-15 22:42:16 +01:00
|
|
|
if (false === $value || (empty($value) && '0' != $value)) {
|
2010-06-24 10:24:08 +01:00
|
|
|
$this->setMessage($constraint->message);
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
return false;
|
|
|
|
}
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
return true;
|
|
|
|
}
|
2011-06-08 11:16:48 +01:00
|
|
|
}
|