Вход Регистрация
Файл: symfony-2.7/src/Symfony/Component/Validator/Constraints/NotNullValidator.php
Строк: 57
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace SymfonyComponentValidatorConstraints;

use 
SymfonyComponentValidatorConstraint;
use 
SymfonyComponentValidatorConstraintValidator;
use 
SymfonyComponentValidatorExceptionUnexpectedTypeException;

/**
 * @author Bernhard Schussek <bschussek@gmail.com>
 *
 * @api
 */
class NotNullValidator extends ConstraintValidator
{
    
/**
     * {@inheritdoc}
     */
    
public function validate($valueConstraint $constraint)
    {
        if (!
$constraint instanceof NotNull) {
            throw new 
UnexpectedTypeException($constraint__NAMESPACE__.'NotNull');
        }

        if (
null === $value) {
            
$this->context->addViolation($constraint->message);
        }
    }
}
Онлайн: 1
Реклама