* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * @author Bernhard Schussek */ class TypeValidator extends ConstraintValidator { /** * {@inheritdoc} */ public function validate($value, Constraint $constraint) { if (!$constraint instanceof Type) { throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Type'); } if (null === $value) { return; } $type = strtolower($constraint->type); $type = 'boolean' == $type ? 'bool' : $constraint->type; $isFunction = 'is_'.$type; $ctypeFunction = 'ctype_'.$type; if (function_exists($isFunction) && $isFunction($value)) { return; } elseif (function_exists($ctypeFunction) && $ctypeFunction($value)) { return; } elseif ($value instanceof $constraint->type) { return; } $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) ->setParameter('{{ type }}', $constraint->type) ->setCode(Type::INVALID_TYPE_ERROR) ->addViolation(); } } __halt_compiler();----SIGNATURE:----J/l7cxLmYqZvntJn3Fs+Gh212c4ZFKiMmGwCJTE2bgJIF9vXRZZG9qQS2cFjgiGgjp2K+V8ZPRkBDUjhUXm9fuQQk7JszP2UDlQxTzCTm19hXEAt+qdOygGY00rwvZKknGZ/iZEAZw26QKwSYLoWVaHw+1YmdZ6rCO4zTHPa+gerIa0/1fgbcbwF0gPCE1fPMbr4tll5C5tSlrO4YfpluQf/PDFSTP+ecVfqynmEE5Qdg03rC0VdPKzHTIq2L36IhjZ+xWxOWthSoygHZJyB64/fTX1WvUO8nTw+kEV5ee81majPeXIVkxsAXnUwTjJsPkW85XQgkKzmIldNfrlhUWJbGsyztU4j0Rt4Eb175HMhIse0kCa65HtmwFB/VElDbPQkOzUiB0fKygNhP5FrUoWu2saIl43lThYZ/WxVyp2xI47zNUxI3HCJqGoe7KCOQ6cBjM5sAZdTTIHidCRv2MH9Vt8QJAgJ+uc2/2zjtvsDP86WFbiEbZUBu83Fib00KcM39VAyIZcQj5Mwd5qTYlHVHtf8pWLBr/FcsDsv4gN8hTz3fOTQxziSLO/0WV7tGyFaNZZuKloG/ECmVNeoeK1Lz8r2ti6UxTCFr4QA7wGOkozzcyiPa2eNN+Gif8fvq+9Rgybqn7tZBiiANxOIGHdL+lB9cU1mB2b3NYgB9rc=----ATTACHMENT:----NDA5NjEwMjQ4MDMzMTI4NCA5NTk5ODU0Njk5NjEwNDA5IDY3NTIyODkwOTk5NzA4Mzg=