prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
he 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 Symfony\Component\Validator\Constraints;
/**
* Validates that a value is less than or equal to another va... | bstractComparison
{
public const TOO_HIGH_ERROR = '30fbb013-d015-4232-8b3b-8f3be97a7e14';
protected const ERROR_NAMES = [
self::TOO_HIGH_ERROR => 'TOO_HIGH_ERROR',
];
public string $message = 'This value should be less than or equ | ute::IS_REPEATABLE)]
class LessThanOrEqual extends A | {
"filepath": "src/Symfony/Component/Validator/Constraints/LessThanOrEqual.php",
"language": "php",
"file_size": 887,
"cut_index": 547,
"middle_length": 52
} |
ge.
*
* (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 Symfony\Component\Validator\Constraints;
use Symfony\Component\Intl\Locales;
use Symfony\Component\Validator\Constraint;
u... | ss Locale extends Constraint
{
public const NO_SUCH_LOCALE_ERROR = 'a0af4293-1f1a-4a1c-a328-979cba6182a2';
protected const ERROR_NAMES = [
self::NO_SUCH_LOCALE_ERROR => 'NO_SUCH_LOCALE_ERROR',
];
public string $message = 'This val | tc.).
*
* @see https://unicode-org.github.io/icu/userguide/locale/
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
cla | {
"filepath": "src/Symfony/Component/Validator/Constraints/Locale.php",
"language": "php",
"file_size": 2143,
"cut_index": 563,
"middle_length": 229
} |
*
* 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\Exc... | p-implementation-of-bank-card-luhn-algorithm/
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class LuhnValidator extends ConstraintValidator
{
public function validate(mixed $value, Constraint $constraint): void
{
if (!$constraint i | hat are used to test this
* class, please see the LuhnValidatorTest class.
*
* @see http://en.wikipedia.org/wiki/Luhn_algorithm
*
* @author Tim Nagel <t.nagel@infinite.net.au>
* @author Greg Knapp http://gregk.me/2011/ph | {
"filepath": "src/Symfony/Component/Validator/Constraints/LuhnValidator.php",
"language": "php",
"file_size": 3198,
"cut_index": 614,
"middle_length": 229
} |
*
* 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\Exc... | ypeException($constraint, MacAddress::class);
}
if (null === $value || '' === $value) {
return;
}
if (!\is_scalar($value) && !$value instanceof \Stringable) {
throw new UnexpectedValueException($val | go.de>
*/
class MacAddressValidator extends ConstraintValidator
{
public function validate(mixed $value, Constraint $constraint): void
{
if (!$constraint instanceof MacAddress) {
throw new UnexpectedT | {
"filepath": "src/Symfony/Component/Validator/Constraints/MacAddressValidator.php",
"language": "php",
"file_size": 3949,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (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 Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Excep... | self::COMPROMISED_PASSWORD_ERROR => 'COMPROMISED_PASSWORD_ERROR',
];
public string $message = 'This password has been leaked in a data breach, it must not be used. Please use another password.';
public int $threshold = 1;
public bool | tribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class NotCompromisedPassword extends Constraint
{
public const COMPROMISED_PASSWORD_ERROR = 'd9bcdbfe-a9d6-4bfa-a8ff-da5fd93e0f6d';
protected const ERROR_NAMES = [
| {
"filepath": "src/Symfony/Component/Validator/Constraints/NotCompromisedPassword.php",
"language": "php",
"file_size": 2113,
"cut_index": 563,
"middle_length": 229
} |
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 Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraint... | OR_NAMES = [
self::IS_NULL_ERROR => 'IS_NULL_ERROR',
];
public string $message = 'This value should not be null.';
/**
* @param string[]|null $groups
*/
public function __construct(?array $options = null, ?string $messag | \Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class NotNull extends Constraint
{
public const IS_NULL_ERROR = 'ad32d13f-c3d4-423b-909a-857b961eb720';
protected const ERR | {
"filepath": "src/Symfony/Component/Validator/Constraints/NotNull.php",
"language": "php",
"file_size": 1392,
"cut_index": 524,
"middle_length": 229
} |
ge.
*
* (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 Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Excep... | H_VERY_WEAK = 0;
public const STRENGTH_WEAK = 1;
public const STRENGTH_MEDIUM = 2;
public const STRENGTH_STRONG = 3;
public const STRENGTH_VERY_STRONG = 4;
public const PASSWORD_STRENGTH_ERROR = '4234df00-45dd-49a4-b303-a75dbf8b10d8';
| Florent Morselli <florent.morselli@spomky-labs.com>
*/
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
final class PasswordStrength extends Constraint
{
public const STRENGT | {
"filepath": "src/Symfony/Component/Validator/Constraints/PasswordStrength.php",
"language": "php",
"file_size": 2286,
"cut_index": 563,
"middle_length": 229
} |
*
* 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\Exc... | traint): void
{
if (!$constraint instanceof Issn) {
throw new UnexpectedTypeException($constraint, Issn::class);
}
if (null === $value || '' === $value) {
return;
}
if (!\is_scalar($valu | aj@garcialagar.es>
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @see https://en.wikipedia.org/wiki/Issn
*/
class IssnValidator extends ConstraintValidator
{
public function validate(mixed $value, Constraint $cons | {
"filepath": "src/Symfony/Component/Validator/Constraints/IssnValidator.php",
"language": "php",
"file_size": 4142,
"cut_index": 614,
"middle_length": 229
} |
*
* 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\Exc... |
if (null === $value) {
return;
}
if (!\is_scalar($value) && !$value instanceof \Stringable) {
throw new UnexpectedValueException($value, 'string');
}
$stringValue = (string) $value;
| nstraintValidator
{
public function validate(mixed $value, Constraint $constraint): void
{
if (!$constraint instanceof Length) {
throw new UnexpectedTypeException($constraint, Length::class);
} | {
"filepath": "src/Symfony/Component/Validator/Constraints/LengthValidator.php",
"language": "php",
"file_size": 4324,
"cut_index": 614,
"middle_length": 229
} |
?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 Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator... | ntf('Passing an array of options to configure the "%s" constraint is no longer supported.', static::class));
}
parent::__construct(0, null, $message, $groups, $payload);
}
public function validatedBy(): string
{
return | intTrait
{
public function __construct(?array $options = null, ?string $message = null, ?array $groups = null, mixed $payload = null)
{
if (null !== $options) {
throw new InvalidArgumentException(\spri | {
"filepath": "src/Symfony/Component/Validator/Constraints/ZeroComparisonConstraintTrait.php",
"language": "php",
"file_size": 1035,
"cut_index": 513,
"middle_length": 229
} |
*
* 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\Exc... | CTION_LEVEL => [
'code' => NoSuspiciousCharacters::RESTRICTION_LEVEL_ERROR,
'messageProperty' => 'restrictionLevelMessage',
],
NoSuspiciousCharacters::CHECK_INVISIBLE => [
'code' => NoSuspiciousCharacters | ator extends ConstraintValidator
{
private const CHECK_RESTRICTION_LEVEL = 16;
private const CHECK_SINGLE_SCRIPT = 16;
private const CHECK_CHAR_LIMIT = 64;
private const CHECK_ERROR = [
self::CHECK_RESTRI | {
"filepath": "src/Symfony/Component/Validator/Constraints/NoSuspiciousCharactersValidator.php",
"language": "php",
"file_size": 3340,
"cut_index": 614,
"middle_length": 229
} |
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 Symfony\Component\Validator\Constraints;
/**
* Validates that a value is not equal to a... | ds AbstractComparison
{
public const IS_EQUAL_ERROR = 'aa2e33da-25c8-4d76-8c6c-812f02ea89dd';
protected const ERROR_NAMES = [
self::IS_EQUAL_ERROR => 'IS_EQUAL_ERROR',
];
public string $message = 'This value should not be equal to | | \Attribute::IS_REPEATABLE)]
class NotEqualTo exten | {
"filepath": "src/Symfony/Component/Validator/Constraints/NotEqualTo.php",
"language": "php",
"file_size": 864,
"cut_index": 529,
"middle_length": 52
} |
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 Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraint... | [
self::INVALID_JSON_ERROR => 'INVALID_JSON_ERROR',
];
public string $message = 'This value should be valid JSON.';
/**
* @param string[]|null $groups
*/
public function __construct(?array $options = null, ?string $messa | ttribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Json extends Constraint
{
public const INVALID_JSON_ERROR = '0789c8ad-2d2b-49a4-8356-e2ce63998504';
protected const ERROR_NAMES = | {
"filepath": "src/Symfony/Component/Validator/Constraints/Json.php",
"language": "php",
"file_size": 1393,
"cut_index": 524,
"middle_length": 229
} |
/*
* 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 Symfony\Component\Validator\Mapping;
/**
* Specifies how the auto-mapping f... | */
public const NONE = 0;
/**
* Explicitly enabled.
*/
public const ENABLED = 1;
/**
* Explicitly disabled.
*/
public const DISABLED = 2;
/**
* Not instantiable.
*/
private function __construc | ured regex.
| {
"filepath": "src/Symfony/Component/Validator/Mapping/AutoMappingStrategy.php",
"language": "php",
"file_size": 805,
"cut_index": 517,
"middle_length": 14
} |
buted with this source code.
*/
namespace Symfony\Component\Validator\Constraints;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
use Symfony\Component\Validator\Exception\InvalidArgumentExcepti... | ic const INVALID_CHARACTERS_ERROR = 'ad9a9798-7a99-4df7-8ce9-46e416a1e60b';
public const NOT_IN_RANGE_ERROR = '04b91c99-a946-4221-afc5-e65ebac401eb';
public const TOO_HIGH_ERROR = '2d28afcb-e32e-45fb-a815-01c431a86a69';
public const TOO_LOW_ERR | ween some minimum and maximum.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Range extends Constraint
{
publ | {
"filepath": "src/Symfony/Component/Validator/Constraints/Range.php",
"language": "php",
"file_size": 5793,
"cut_index": 716,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\MappingException;
/**
* Base loader for v... | m>
*/
abstract class AbstractLoader implements LoaderInterface
{
/**
* The namespace to load constraints from by default.
*/
public const DEFAULT_NAMESPACE = '\\Symfony\\Component\\Validator\\Constraints\\';
protected array $namespa | s. Constraints can also be loaded using their fully
* qualified class names. At last, namespace aliases can be defined to load
* constraints with the syntax "alias:ShortName".
*
* @author Bernhard Schussek <bschussek@gmail.co | {
"filepath": "src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php",
"language": "php",
"file_size": 3118,
"cut_index": 614,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Validator;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\GroupSequence;
use Symfony\Component\Validator... | aints.
*
* If no constraint is passed, the constraint
* {@link \Symfony\Component\Validator\Constraints\Valid} is assumed.
*
* @param Constraint|Constraint[]|null $constraints The constraint(s) to validate | s PHP values against constraints.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
interface ValidatorInterface extends MetadataFactoryInterface
{
/**
* Validates a value against a constraint or a list of constr | {
"filepath": "src/Symfony/Component/Validator/Validator/ValidatorInterface.php",
"language": "php",
"file_size": 4140,
"cut_index": 614,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Validator\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Dumper;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputArgument;
... | fony\Component\Validator\Mapping\CascadingStrategy;
use Symfony\Component\Validator\Mapping\ClassMetadataInterface;
use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface;
use Symfony\Component\Validator\Mapping\GenericMetadata;
use Symfo | ymfonyStyle;
use Symfony\Component\Finder\Exception\DirectoryNotFoundException;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Mapping\AutoMappingStrategy;
use Sym | {
"filepath": "src/Symfony/Component/Validator/Command/DebugCommand.php",
"language": "php",
"file_size": 8352,
"cut_index": 716,
"middle_length": 229
} |
ge.
*
* (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 Symfony\Component\Validator\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\Constraint;
use Symfony... | t->addImplicitGroupName('Foo');
$this->assertEquals(['Default', 'Foo'], $constraint->groups);
}
public function testGetTargetsCanBeString()
{
$constraint = new ClassConstraint();
$this->assertEquals('class', $constrain | \Component\Validator\Tests\Fixtures\CustomRegex;
class ConstraintTest extends TestCase
{
public function testAddDefaultGroupAddsGroup()
{
$constraint = new ConstraintA(null, null, ['Default']);
$constrain | {
"filepath": "src/Symfony/Component/Validator/Tests/ConstraintTest.php",
"language": "php",
"file_size": 2416,
"cut_index": 563,
"middle_length": 229
} |
hp
/*
* 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 Symfony\Component\Validator\Tests;
use PHPUnit\Framework\TestCase;
use Sym... | tInstance(new DummyConstraint()));
}
public function testPredefinedGetInstance()
{
$validator = new DummyConstraintValidator();
$factory = new ConstraintValidatorFactory([DummyConstraintValidator::class => $validator]);
| lass ConstraintValidatorFactoryTest extends TestCase
{
public function testGetInstance()
{
$factory = new ConstraintValidatorFactory();
$this->assertInstanceOf(DummyConstraintValidator::class, $factory->ge | {
"filepath": "src/Symfony/Component/Validator/Tests/ConstraintValidatorFactoryTest.php",
"language": "php",
"file_size": 1086,
"cut_index": 515,
"middle_length": 229
} |
ge.
*
* (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 Symfony\Component\Validator\Tests;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symf... | me($expected, (new TestFormatValueConstraintValidator())->formatValueProxy($value, $format));
}
public static function formatValueProvider(): array
{
$defaultTimezone = date_default_timezone_get();
date_default_timezone_set('Eu | e
{
use IcuCompatibilityTrait;
#[DataProvider('formatValueProvider')]
public function testFormatValue(string $expected, mixed $value, int $format = 0)
{
\Locale::setDefault('en');
$this->assertSa | {
"filepath": "src/Symfony/Component/Validator/Tests/ConstraintValidatorTest.php",
"language": "php",
"file_size": 2958,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Tests;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\ConstraintViolation;
use Sy... | getViolation('Error');
$this->list = new ConstraintViolationList([$violation]);
$this->assertCount(1, $this->list);
$this->assertSame($violation, $this->list[0]);
}
public function testAdd()
{
$violation = $thi | {
$this->list = new ConstraintViolationList();
}
public function testInit()
{
$this->assertCount(0, $this->list);
}
public function testInitWithViolations()
{
$violation = $this-> | {
"filepath": "src/Symfony/Component/Validator/Tests/ConstraintViolationListTest.php",
"language": "php",
"file_size": 4793,
"cut_index": 614,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\Tests\Fixtures\Custom... | Root.property.path:
Array
EOF;
$this->assertSame($expected, (string) $violation);
}
public function testToStringHandlesArrayRoots()
{
$violation = new ConstraintViolation(
'42 ca | = new ConstraintViolation(
'Array',
'{{ value }}',
['{{ value }}' => [1, 2, 3]],
'Root',
'property.path',
null
);
$expected = <<<'EOF'
| {
"filepath": "src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php",
"language": "php",
"file_size": 4622,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (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 Symfony\Component\Validator\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Container;
us... | yTest extends TestCase
{
public function testGetInstanceCreatesValidator()
{
$factory = new ContainerConstraintValidatorFactory(new Container());
$this->assertInstanceOf(DummyConstraintValidator::class, $factory->getInstance(new Dum | \Component\Validator\Exception\ValidatorException;
use Symfony\Component\Validator\Tests\Fixtures\DummyConstraint;
use Symfony\Component\Validator\Tests\Fixtures\DummyConstraintValidator;
class ContainerConstraintValidatorFactor | {
"filepath": "src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php",
"language": "php",
"file_size": 2256,
"cut_index": 563,
"middle_length": 229
} |
he 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 Symfony\Component\Validator\Tests;
trait IcuCompatibilityTrait
{
/**
* Normalized spaces in date ... | anner.
*/
private static function normalizeIcuSpaces(string $input): string
{
if (\defined('INTL_ICU_VERSION') && version_compare(\INTL_ICU_VERSION, '72.1', '>=')) {
return $input;
}
return str_replace("\u{ | s us to write expectations in a forward-compatible m | {
"filepath": "src/Symfony/Component/Validator/Tests/IcuCompatibilityTrait.php",
"language": "php",
"file_size": 885,
"cut_index": 547,
"middle_length": 52
} |
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 Symfony\Component\Validator\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validat... | ssertEquals('test@example.com', $validator('test@example.com'));
}
public function testCreateCallableInvalid()
{
$validator = Validation::createCallable(new Blank());
try {
$validator('test');
$this->fai | *
* @author Jan Vernieuwe <jan.vernieuwe@phpro.be>
*/
class ValidationTest extends TestCase
{
public function testCreateCallableValid()
{
$validator = Validation::createCallable(new NotBlank());
$this->a | {
"filepath": "src/Symfony/Component/Validator/Tests/ValidationTest.php",
"language": "php",
"file_size": 1917,
"cut_index": 537,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Tests;
use PHPUnit\Framework\TestCase;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Translation\IdentityTranslator;
use Symfony\Co... | ic function testAddObjectInitializer()
{
$this->assertSame($this->builder, $this->builder->addObjectInitializer(
$this->createStub(ObjectInitializerInterface::class)
));
}
public function testAddObjectInitializers() | ponent\Validator\ValidatorBuilder;
class ValidatorBuilderTest extends TestCase
{
private ValidatorBuilder $builder;
protected function setUp(): void
{
$this->builder = new ValidatorBuilder();
}
publ | {
"filepath": "src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php",
"language": "php",
"file_size": 3371,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (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 Symfony\Component\Validator\Tests\DataCollector;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\Constrain... | idatorInterface::class);
$validator = new TraceableValidator($originalValidator);
$collector = new ValidatorDataCollector($validator);
$violations = new ConstraintViolationList([
$this->createStub(ConstraintViolation:: | lidator;
use Symfony\Component\Validator\Validator\ValidatorInterface;
class ValidatorDataCollectorTest extends TestCase
{
public function testCollectsValidatorCalls()
{
$originalValidator = $this->createStub(Val | {
"filepath": "src/Symfony/Component/Validator/Tests/DataCollector/ValidatorDataCollectorTest.php",
"language": "php",
"file_size": 2413,
"cut_index": 563,
"middle_length": 229
} |
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 Symfony\Component\Validator\Tests\Util;
use PHPUnit\Framework\Attributes\DataProvid... | turn [
['foo', '', 'foo', 'It returns the basePath if subPath is empty'],
['', 'bar', 'bar', 'It returns the subPath if basePath is empty'],
['foo', 'bar', 'foo.bar', 'It append the subPath to the basePath'],
| testAppend($basePath, $subPath, $expectedPath, $message)
{
$this->assertSame($expectedPath, PropertyPath::append($basePath, $subPath), $message);
}
public static function provideAppendPaths()
{
re | {
"filepath": "src/Symfony/Component/Validator/Tests/Util/PropertyPathTest.php",
"language": "php",
"file_size": 1275,
"cut_index": 524,
"middle_length": 229
} |
/*
* 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 Symfony\Component\Validator\Tests\Fixtures;
use Symfony\Component\Validator\C... | parent::__construct(null, $groups);
$this->property1 = $property1;
$this->property2 = $property2;
}
public function getTargets(): string|array
{
return [self::PROPERTY_CONSTRAINT, self::CLASS_CONSTRAINT];
}
}
| null)
{
| {
"filepath": "src/Symfony/Component/Validator/Tests/Fixtures/ConstraintA.php",
"language": "php",
"file_size": 788,
"cut_index": 518,
"middle_length": 14
} |
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 Symfony\Component\Validator\Tests\Fixtures;
use Symfony\Component\Validat... | ::__construct(null, $groups, $payload);
}
public function getRequiredOptions(): array
{
return ['option1'];
}
public function getTargets(): string|array
{
return [self::PROPERTY_CONSTRAINT, self::CLASS_CONSTRAINT]; | parent | {
"filepath": "src/Symfony/Component/Validator/Tests/Fixtures/ConstraintWithRequiredOptionAndConstructor.php",
"language": "php",
"file_size": 793,
"cut_index": 514,
"middle_length": 14
} |
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 Symfony\Component\Validator\Tests\Fixtures;
/**
* This class is a hand written simplified versi... | this->array);
}
public function offsetGet($offset): mixed
{
return $this->array[$offset];
}
public function offsetSet($offset, $value): void
{
if (null === $offset) {
$this->array[] = $value;
} | able
{
private $array;
public function __construct(?array $array = null)
{
$this->array = $array ?: [];
}
public function offsetExists($offset): bool
{
return \array_key_exists($offset, $ | {
"filepath": "src/Symfony/Component/Validator/Tests/Fixtures/CustomArrayObject.php",
"language": "php",
"file_size": 1561,
"cut_index": 537,
"middle_length": 229
} |
?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 Symfony\Component\Validator\Tests\Fixtures;
use Symfony\Component\Valida... | straint extends Compound
{
protected function getConstraints(array $options): array
{
return [
new NotBlank(),
new Length(max: 3),
new Regex('/[a-z]+/'),
new Regex('/[0-9]+/'),
];
| mmyCompoundCon | {
"filepath": "src/Symfony/Component/Validator/Tests/Fixtures/DummyCompoundConstraint.php",
"language": "php",
"file_size": 787,
"cut_index": 513,
"middle_length": 14
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Validator;
use Psr\Container\ContainerInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\GroupSeq... | ymfony\Component\Validator\ObjectInitializerInterface;
/**
* Recursive implementation of {@link ValidatorInterface}.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class RecursiveValidator implements ValidatorInterface
{
/**
* Creates | ontextFactoryInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface;
use Symfony\Component\Validator\Mapping\MetadataInterface;
use S | {
"filepath": "src/Symfony/Component/Validator/Validator/RecursiveValidator.php",
"language": "php",
"file_size": 3833,
"cut_index": 614,
"middle_length": 229
} |
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 Symfony\Component\Validator\Constraints;
use Symfony\Component\Intl\Languages;
use Symfony\Compo... | $value, Constraint $constraint): void
{
if (!$constraint instanceof Language) {
throw new UnexpectedTypeException($constraint, Language::class);
}
if (null === $value || '' === $value) {
return;
| xpectedValueException;
/**
* Validates whether a value is a valid language code.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class LanguageValidator extends ConstraintValidator
{
public function validate(mixed | {
"filepath": "src/Symfony/Component/Validator/Constraints/LanguageValidator.php",
"language": "php",
"file_size": 1561,
"cut_index": 537,
"middle_length": 229
} |
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 Symfony\Component\Validator\Mapping;
/**
* Specifies whether an object should be c... | object and
* cascade each object or collection contained within, unless iteration is
* prohibited by the specified {@link TraversalStrategy}.
*
* Although the constants currently represent a boolean switch, they are
* implemented as bit mask in order | class metadata for that object and validate the
* object against that metadata.
*
* If no metadata is found for a cascaded object, and if that object implements
* {@link \Traversable}, the node traverser will iterate over the | {
"filepath": "src/Symfony/Component/Validator/Mapping/CascadingStrategy.php",
"language": "php",
"file_size": 1434,
"cut_index": 524,
"middle_length": 229
} |
ge.
*
* (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 Symfony\Component\Validator\Mapping;
use Symfony\Component\Validator\Constraints\GroupSequence;
use Symfony\Component\Vali... | or not.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @see MetadataInterface
* @see GroupSequence
* @see GroupSequenceProviderInterface
* @see TraversalStrategy
*/
interface ClassMetadataInterface extends MetadataInterface
{
/**
| object
* and its properties should be validated.
*
* Additionally, the metadata stores whether the "Default" group is overridden
* by a group sequence for that class and whether instances of that class
* should be traversed | {
"filepath": "src/Symfony/Component/Validator/Mapping/ClassMetadataInterface.php",
"language": "php",
"file_size": 2805,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\Composite;
use Symfony\Component\Validator\Excep... | data extends GenericMetadata implements PropertyMetadataInterface
{
private string $class;
private string $name;
private string $property;
/**
* @var \ReflectionMethod[]|\ReflectionProperty[]
*/
private array $reflMember = [] | implementing the {@link newReflectionMember()} method.
*
* This class supports serialization and cloning.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @see PropertyMetadataInterface
*/
abstract class MemberMeta | {
"filepath": "src/Symfony/Component/Validator/Mapping/MemberMetadata.php",
"language": "php",
"file_size": 3931,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (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 Symfony\Component\Validator\Mapping;
use Symfony\Component\Validator\Exception\ValidatorException;
/**
* Stores all meta... | mberMetadata
{
/**
* @param string $class The class this property is defined on
* @param string $name The name of this property
*
* @throws ValidatorException
*/
public function __construct(string $class, string $name)
| ivate and
* protected properties is supported.
*
* This class supports serialization and cloning.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @see PropertyMetadataInterface
*/
class PropertyMetadata extends Me | {
"filepath": "src/Symfony/Component/Validator/Mapping/PropertyMetadata.php",
"language": "php",
"file_size": 2915,
"cut_index": 563,
"middle_length": 229
} |
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 Symfony\Component\Validator\Mapping;
/**
* Specifies whether and how a traversable object shoul... | ersal strategy is ignored for arrays. Arrays are always iterated.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @see CascadingStrategy
*/
class TraversalStrategy
{
/**
* Specifies that a node's value should be iterated only if it is | the node's traversal strategy will be checked.
* Depending on the requested traversal strategy, the node traverser will
* iterate over the object and cascade each object or collection returned by
* the iterator.
*
* The trav | {
"filepath": "src/Symfony/Component/Validator/Mapping/TraversalStrategy.php",
"language": "php",
"file_size": 1511,
"cut_index": 537,
"middle_length": 229
} |
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 Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\Validator\Exception\MappingExc... | protected string $methodName = 'loadValidatorMetadata',
) {
}
public function loadClassMetadata(ClassMetadata $metadata): bool
{
/** @var \ReflectionClass $reflClass */
$reflClass = $metadata->getReflectionClass();
| l.com>
*/
class StaticMethodLoader implements LoaderInterface
{
/**
* Creates a new loader.
*
* @param string $methodName The name of the static method to call
*/
public function __construct(
| {
"filepath": "src/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php",
"language": "php",
"file_size": 1673,
"cut_index": 537,
"middle_length": 229
} |
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 Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\TestCase;
use Symfony\Compo... | ption(ConstraintDefinitionException::class);
new AtLeastOneOf([
'foo',
]);
}
public function testRejectValidConstraint()
{
$this->expectException(ConstraintDefinitionException::class);
new AtLeastOne | ator\Exception\MissingOptionsException;
/**
* @author Przemysław Bogusz <przemyslaw.bogusz@tubotax.pl>
*/
class AtLeastOneOfTest extends TestCase
{
public function testRejectNonConstraints()
{
$this->expectExce | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/AtLeastOneOfTest.php",
"language": "php",
"file_size": 1658,
"cut_index": 537,
"middle_length": 229
} |
ony\Component\Validator\Constraints\AtLeastOneOfValidator;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\Collection;
use Symfony\Component\Validator\Constraints\Count;
use Symfony\Component\Validator\Constraints\Country;
use Symfony\Component\Validator\Constraints\Divis... | t\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\LessThan;
use Symfony\Component\Validator\Constraints\Negative;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\Range;
use Symfony\ | ent\Validator\Constraints\GreaterThanOrEqual;
use Symfony\Component\Validator\Constraints\IdenticalTo;
use Symfony\Component\Validator\Constraints\IsNull;
use Symfony\Component\Validator\Constraints\Language;
use Symfony\Componen | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/AtLeastOneOfValidatorTest.php",
"language": "php",
"file_size": 11732,
"cut_index": 921,
"middle_length": 229
} |
nent\Validator\Constraints\BicValidator;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
use Symfony\Component\Validator\Exception\InvalidArgumentException;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Com... | (null, new Bic());
$this->assertNoViolation();
}
public function testEmptyStringIsValid()
{
$this->validate('', new Bic());
$this->assertNoViolation();
}
public function testValidComparisonToPropertyPath()
| ass BicValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator(): BicValidator
{
return new BicValidator();
}
public function testNullIsValid()
{
$this->validate | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php",
"language": "php",
"file_size": 11829,
"cut_index": 921,
"middle_length": 229
} |
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 Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\Attributes\DataProvider;
us... | ew Blank());
$this->assertNoViolation();
}
public function testBlankIsValid()
{
$this->validate('', new Blank());
$this->assertNoViolation();
}
#[DataProvider('getInvalidValues')]
public function testInva | atorTest extends ConstraintValidatorTestCase
{
protected function createValidator(): BlankValidator
{
return new BlankValidator();
}
public function testNullIsValid()
{
$this->validate(null, n | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php",
"language": "php",
"file_size": 1576,
"cut_index": 537,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Validator\Tests\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Constraints\CallbackValidator;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
... | $context->addViolation('My message', ['{{ value }}' => 'foobar']);
return false;
}
public static function validateStatic($object, ExecutionContextInterface $context)
{
$context->addViolation('Static message', ['{{ value | {
$context->addViolation('Callback message', ['{{ value }}' => 'foobar']);
return false;
}
}
class CallbackValidatorTest_Object
{
public function validate(ExecutionContextInterface $context)
{
| {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php",
"language": "php",
"file_size": 7100,
"cut_index": 716,
"middle_length": 229
} |
ge.
*
* (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 Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\Constraints... | loadClassMetadata($metadata));
[$aConstraint] = $metadata->getPropertyMetadata('a')[0]->getConstraints();
self::assertSame([CardScheme::MASTERCARD, CardScheme::VISA], $aConstraint->schemes);
[$bConstraint] = $metadata->getProperty | oader;
class CardSchemeTest extends TestCase
{
public function testAttributes()
{
$metadata = new ClassMetadata(CardSchemeDummy::class);
$loader = new AttributeLoader();
self::assertTrue($loader-> | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/CardSchemeTest.php",
"language": "php",
"file_size": 2176,
"cut_index": 563,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Validator\Constraints\CardScheme;
use Symfony\Component\Validator\Constraints\CardSchemeValidator;
use Symfony\Component\Validator\Test\ConstraintValidatorTest... | w CardScheme(schemes: []));
$this->assertNoViolation();
}
#[DataProvider('getValidNumbers')]
public function testValidNumbers($scheme, $number)
{
$this->validate($number, new CardScheme(schemes: $scheme));
$this-> | public function testNullIsValid()
{
$this->validate(null, new CardScheme(schemes: []));
$this->assertNoViolation();
}
public function testEmptyStringIsValid()
{
$this->validate('', ne | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php",
"language": "php",
"file_size": 6937,
"cut_index": 716,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Validator;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\GroupSequence;
use Symfony\Component\Validator... | return $this
*/
public function atPath(string $path): static;
/**
* Validates a value against a constraint or a list of constraints.
*
* If no constraint is passed, the constraint
* {@link \Symfony\Component\Validator\Cons | **
* Appends the given path to the property path of the context.
*
* If called multiple times, the path will always be reset to the context's
* original path with the given path appended to it.
*
* @ | {
"filepath": "src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php",
"language": "php",
"file_size": 3265,
"cut_index": 614,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Validator;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\GroupSequence;
use Symfony\Component\Validator... | llectedData = [];
public function __construct(
private ValidatorInterface $validator,
protected readonly ?\Closure $disabled = null,
) {
}
public function getCollectedData(): array
{
return $this->collectedData | esetInterface;
/**
* Collects some data about validator calls.
*
* @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
*/
class TraceableValidator implements ValidatorInterface, ResetInterface
{
private array $co | {
"filepath": "src/Symfony/Component/Validator/Validator/TraceableValidator.php",
"language": "php",
"file_size": 3930,
"cut_index": 614,
"middle_length": 229
} |
dator\Constraints\Composite;
use Symfony\Component\Validator\Constraints\GroupSequence;
use Symfony\Component\Validator\Constraints\Traverse;
use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
use Symfony\Component\Validator\Exception\GroupDefinit... | string $defaultGroup;
/**
* @var MemberMetadata[][]
*/
private array $members = [];
/**
* @var PropertyMetadata[]
*/
private array $properties = [];
/**
* @var GetterMetadata[]
*/
private array $get | ing.
*
* @author Bernhard Schussek <bschussek@gmail.com>
* @author Fabien Potencier <fabien@symfony.com>
*/
class ClassMetadata extends GenericMetadata implements ClassMetadataInterface
{
private string $name;
private | {
"filepath": "src/Symfony/Component/Validator/Mapping/ClassMetadata.php",
"language": "php",
"file_size": 15361,
"cut_index": 921,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Validator\Mapping;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\Cascade;
use Symfony\Component\Validator\Constraints\DisableAutoMapping;
use Symfony\Component\Validator\Constraints\EnableAutoMapping;
use Symfony\Co... | */
private array $constraints = [];
/**
* @var array<string, Constraint[]>
*/
private array $constraintsByGroup = [];
/**
* The strategy for cascading objects.
*
* By default, objects are not cascaded.
*
| of {@link Constraint} objects.
*
* This class supports serialization and cloning.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class GenericMetadata implements MetadataInterface
{
/**
* @var Constraint[]
| {
"filepath": "src/Symfony/Component/Validator/Mapping/GenericMetadata.php",
"language": "php",
"file_size": 5865,
"cut_index": 716,
"middle_length": 229
} |
ge.
*
* (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 Symfony\Component\Validator\Mapping;
use Symfony\Component\Validator\Exception\ValidatorException;
/**
* Stores all meta... | or Bernhard Schussek <bschussek@gmail.com>
*
* @see PropertyMetadataInterface
*/
class GetterMetadata extends MemberMetadata
{
/**
* @param string $class The class the getter is defined on
* @param string $property The propert | thod will be used to access the
* property's value.
*
* The getter will be invoked by reflection, so the access of private and
* protected getters is supported.
*
* This class supports serialization and cloning.
*
* @auth | {
"filepath": "src/Symfony/Component/Validator/Mapping/GetterMetadata.php",
"language": "php",
"file_size": 2608,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator... | */
class AttributeLoader implements LoaderInterface
{
/**
* @param array<class-string, class-string[]> $mappedClasses
*/
public function __construct(
private bool $allowAnyClass = true,
private array $mappedClasses = [],
| ng\ClassMetadata;
/**
* Loads validation metadata using PHP attributes.
*
* @author Bernhard Schussek <bschussek@gmail.com>
* @author Alexander M. Turek <me@derrabus.de>
* @author Alexandre Daubois <alex.daubois@gmail.com>
| {
"filepath": "src/Symfony/Component/Validator/Mapping/Loader/AttributeLoader.php",
"language": "php",
"file_size": 4674,
"cut_index": 614,
"middle_length": 229
} |
?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 Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\Valida... | pingStrategy::NONE !== $strategy = $metadata->getAutoMappingStrategy()) {
return AutoMappingStrategy::ENABLED === $strategy;
}
// Fallback on the config
return null !== $classValidatorRegexp && preg_match($classValidato | */
trait AutoMappingTrait
{
private function isAutoMappingEnabledForClass(ClassMetadata $metadata, ?string $classValidatorRegexp = null): bool
{
// Check if AutoMapping constraint is set first
if (AutoMap | {
"filepath": "src/Symfony/Component/Validator/Mapping/Loader/AutoMappingTrait.php",
"language": "php",
"file_size": 1044,
"cut_index": 513,
"middle_length": 229
} |
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 Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\Validator\Exception\MappingExc... | * @param LoaderInterface[] $loaders The metadata loaders to use
*
* @throws MappingException If any of the loaders has an invalid type
*/
public function __construct(
protected array $loaders,
) {
foreach ($loaders a | hain. Once
* {@link loadClassMetadata()} is called, that method will be called on all
* loaders in the chain.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class LoaderChain implements LoaderInterface
{
/**
| {
"filepath": "src/Symfony/Component/Validator/Mapping/Loader/LoaderChain.php",
"language": "php",
"file_size": 1655,
"cut_index": 537,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
use Symfony\Component\PropertyInfo\PropertyListExtractorInterface;
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
use Symfony\Component\TypeIn... | \Constraints\All;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\Type;
use Symfony\Component\Validator\Mapping\AutoMappingStrategy;
use Symfony\Componen | mfony\Component\TypeInfo\Type\NullableType;
use Symfony\Component\TypeInfo\Type\ObjectType;
use Symfony\Component\TypeInfo\Type\WrappingTypeInterface;
use Symfony\Component\TypeInfo\TypeIdentifier;
use Symfony\Component\Validator | {
"filepath": "src/Symfony/Component/Validator/Mapping/Loader/PropertyInfoLoader.php",
"language": "php",
"file_size": 6979,
"cut_index": 716,
"middle_length": 229
} |
ony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Tests\Fixtures;
use Symfony\Component\Validator\Mapping\Loader\FilesLoader as BaseFilesLoader;
use Symfony\Component\Validator\Mapping\Lo... | parent::__construct($paths);
}
protected function getFileLoaderInstance(string $file): LoaderInterface
{
++$this->timesCalled;
return $this->loader;
}
public function getTimesCalled()
{
return $this- | e $loader)
{
$this->loader = $loader;
| {
"filepath": "src/Symfony/Component/Validator/Tests/Fixtures/FilesLoader.php",
"language": "php",
"file_size": 936,
"cut_index": 606,
"middle_length": 52
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Tests\Fixtures\NestedAttribute;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextIn... | Entity extends EntityParent implements EntityInterfaceB
{
#[
Assert\NotNull,
Assert\Range(min: 3),
Assert\All([
new Assert\NotNull(),
new Assert\Range(min: 3),
]),
Assert\All(
| tA;
#[
ConstraintA,
Assert\GroupSequence(['Foo', 'Entity']),
Assert\Callback([CallbackClass::class, 'callback']),
Assert\Sequentially([
new Assert\Expression('this.getFirstName() != null'),
])
]
class | {
"filepath": "src/Symfony/Component/Validator/Tests/Fixtures/NestedAttribute/Entity.php",
"language": "php",
"file_size": 4005,
"cut_index": 614,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exc... | r Daniel Holmes <daniel@danielholmes.org>
*/
abstract class AbstractComparisonValidatorTestCase extends ConstraintValidatorTestCase
{
protected static function addPhp5Dot5Comparisons(array $comparisons)
{
$result = $comparisons;
/ | lue)
{
$this->value = $value;
}
public function __toString(): string
{
return (string) $this->value;
}
public function getValue()
{
return $this->value;
}
}
/**
* @autho | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php",
"language": "php",
"file_size": 4273,
"cut_index": 614,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\Config\Util\XmlUtils;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\MappingException;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
* Loads validation met... | bool
{
if (!isset($this->classes)) {
$this->loadClassesFromXml();
}
if (isset($this->classes[$metadata->getClassName()])) {
$classDescription = $this->classes[$metadata->getClassName()];
$t | array<class-string, \SimpleXMLElement>
*/
protected array $classes;
public function __construct(string $file)
{
$this->file = $file;
}
public function loadClassMetadata(ClassMetadata $metadata): | {
"filepath": "src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php",
"language": "php",
"file_size": 6945,
"cut_index": 716,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Parser as YamlParser;
use Symfony\Component\Yaml\Yam... | ata): bool
{
if (!isset($this->classes)) {
$this->loadClassesFromYaml();
}
if (isset($this->classes[$metadata->getClassName()])) {
$classDescription = $this->classes[$metadata->getClassName()];
| blic function __construct(string $file)
{
$this->file = $file;
}
/**
* Caches the used YAML parser.
*/
private YamlParser $yamlParser;
public function loadClassMetadata(ClassMetadata $metad | {
"filepath": "src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php",
"language": "php",
"file_size": 5709,
"cut_index": 716,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Factory;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Validator\Exception\NoSuchMetadataException;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Mapping\Loader\LoaderInterface;
use Sy... | derInterface} instance to the constructor.
* Whenever a new metadata instance is created, it is passed to the loader,
* which can configure the metadata based on configuration loaded from the
* filesystem or a database. If you want to use multiple loade | iven
* class name or object of that class, a new metadata instance is created and
* returned. On subsequent requests for the same class, the same metadata
* instance will be returned.
*
* You can optionally pass a {@link Loa | {
"filepath": "src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php",
"language": "php",
"file_size": 5519,
"cut_index": 716,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Violation;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Builds {@link \Symfony\Component\Validator\ConstraintViolationInterface... | appended to the current property path of the
* execution context.
*
* @param string $path The property path
*
* @return $this
*/
public function atPath(string $path): static;
/**
* Sets a parameter to be inserte | .
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
interface ConstraintViolationBuilderInterface
{
/**
* Stores the property path at which the violation should be generated.
*
* The passed path will be | {
"filepath": "src/Symfony/Component/Validator/Violation/ConstraintViolationBuilderInterface.php",
"language": "php",
"file_size": 3193,
"cut_index": 614,
"middle_length": 229
} |
xecutionContext;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
use Symfony\Component\Validator\Exception\NoSuchMetadataException;
use Symfony\Component\Validator\Exception\RuntimeException;
use Symfony\Component\Validator\Exce... | face;
use Symfony\Component\Validator\Mapping\GenericMetadata;
use Symfony\Component\Validator\Mapping\GetterMetadata;
use Symfony\Component\Validator\Mapping\MetadataInterface;
use Symfony\Component\Validator\Mapping\PropertyMetadataInterface;
use Symfony | dator\GroupSequenceProviderInterface;
use Symfony\Component\Validator\Mapping\CascadingStrategy;
use Symfony\Component\Validator\Mapping\ClassMetadataInterface;
use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInter | {
"filepath": "src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php",
"language": "php",
"file_size": 31732,
"cut_index": 1331,
"middle_length": 229
} |
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 Symfony\Component\Validator\Mapping;
use Symfony\Component\Validator\Constraint;
/**
* A conta... | raversalStrategy
*/
interface MetadataInterface
{
/**
* Returns the strategy for cascading objects.
*
* @see CascadingStrategy
*/
public function getCascadingStrategy(): int;
/**
* Returns the strategy for traversing | ores whether objects should be validated
* against their class' metadata and whether traversable objects should be
* traversed or not.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @see CascadingStrategy
* @see T | {
"filepath": "src/Symfony/Component/Validator/Mapping/MetadataInterface.php",
"language": "php",
"file_size": 1512,
"cut_index": 537,
"middle_length": 229
} |
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 Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\Validator\Excepti... | le
*/
public function __construct(
protected string $file,
) {
if (!is_file($file)) {
throw new MappingException(\sprintf('The mapping file "%s" does not exist.', $file));
}
if (!is_readable($file)) | abstract class FileLoader extends AbstractLoader
{
/**
* Creates a new loader.
*
* @param string $file The mapping file to load
*
* @throws MappingException If the file does not exist or is not readab | {
"filepath": "src/Symfony/Component/Validator/Mapping/Loader/FileLoader.php",
"language": "php",
"file_size": 1288,
"cut_index": 524,
"middle_length": 229
} |
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 Symfony\Component\Validator\Tests\Fixtures;
use Symfony\Component\Validator\Exception\NoSuchMeta... | $class = $class::class;
}
if (!\is_string($class)) {
throw new NoSuchMetadataException(sprintf('No metadata for type "%s".', get_debug_type($class)));
}
if (!isset($this->metadatas[$class])) {
| taFactoryInterface
{
protected $metadatas = [];
public function getMetadataFor($class): MetadataInterface
{
$objectId = null;
if (\is_object($class)) {
$objectId = spl_object_id($class);
| {
"filepath": "src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php",
"language": "php",
"file_size": 1984,
"cut_index": 537,
"middle_length": 229
} |
ackage.
*
* (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 Symfony\Component\Validator\Tests\Fixtures\NestedAttribute;
use Symfony\Component\Validator\Constraints as Assert;
use... | irstName;
public $lastName;
protected $sequence = [];
public function __construct($sequence)
{
$this->sequence = $sequence;
}
public function getGroupSequence(): array|GroupSequence
{
return $this->sequence;
| ments GroupSequenceProviderInterface
{
public $f | {
"filepath": "src/Symfony/Component/Validator/Tests/Fixtures/NestedAttribute/GroupSequenceProviderEntity.php",
"language": "php",
"file_size": 874,
"cut_index": 559,
"middle_length": 52
} |
ge.
*
* (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 Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Valida... | AllValidator
{
return new AllValidator();
}
public function testNullIsValid()
{
$this->validate(null, new All(new Range(min: 4)));
$this->assertNoViolation();
}
public function testThrowsExceptionIfNotTrav | ny\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class AllValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator(): | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php",
"language": "php",
"file_size": 2270,
"cut_index": 563,
"middle_length": 229
} |
<?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 Symfony\Component\Validator\Mapping\Factory;
use Symfony\Component\Vali... | yInterface
{
public function getMetadataFor(mixed $value): MetadataInterface
{
throw new LogicException('This class does not support metadata.');
}
public function hasMetadataFor(mixed $value): bool
{
return false;
| t to validate values against
* constraints only and you don't need to add constraints to classes and
* properties.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class BlackHoleMetadataFactory implements MetadataFactor | {
"filepath": "src/Symfony/Component/Validator/Mapping/Factory/BlackHoleMetadataFactory.php",
"language": "php",
"file_size": 1001,
"cut_index": 512,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Violation;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\Const... | null;
private ?string $code = null;
private mixed $cause = null;
public function __construct(
private ConstraintViolationList $violations,
private ?Constraint $constraint,
private string|\Stringable $message,
p | rInterface}.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @internal
*/
class ConstraintViolationBuilder implements ConstraintViolationBuilderInterface
{
private string $propertyPath;
private ?int $plural = | {
"filepath": "src/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php",
"language": "php",
"file_size": 3534,
"cut_index": 614,
"middle_length": 229
} |
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 Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraint... | hrow new UnexpectedTypeException($constraint, NotBlank::class);
}
if ($constraint->allowNull && null === $value) {
return;
}
if (\is_string($value) && null !== $constraint->normalizer) {
$value = ($ | in Dunglas <dunglas@gmail.com>
*/
class NotBlankValidator extends ConstraintValidator
{
public function validate(mixed $value, Constraint $constraint): void
{
if (!$constraint instanceof NotBlank) {
t | {
"filepath": "src/Symfony/Component/Validator/Constraints/NotBlankValidator.php",
"language": "php",
"file_size": 1359,
"cut_index": 524,
"middle_length": 229
} |
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 Symfony\Component\Validator\Mapping\Loader;
/**
* Base loader for loading validati... | ruct($this->getFileLoaders($paths));
}
/**
* Returns an array of file loaders for the given file paths.
*
* @return LoaderInterface[]
*/
protected function getFileLoaders(array $paths): array
{
$loaders = [];
| */
abstract class FilesLoader extends LoaderChain
{
/**
* Creates a new loader.
*
* @param array $paths An array of file paths
*/
public function __construct(array $paths)
{
parent::__const | {
"filepath": "src/Symfony/Component/Validator/Mapping/Loader/FilesLoader.php",
"language": "php",
"file_size": 1302,
"cut_index": 524,
"middle_length": 229
} |
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 Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\TestCase;
use Symfony\Compo... | xception::class);
new All([
'foo',
]);
}
public function testRejectValidConstraint()
{
$this->expectException(ConstraintDefinitionException::class);
new All([
new Valid(),
]);
| ption\MissingOptionsException;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class AllTest extends TestCase
{
public function testRejectNonConstraints()
{
$this->expectException(ConstraintDefinitionE | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/AllTest.php",
"language": "php",
"file_size": 1576,
"cut_index": 537,
"middle_length": 229
} |
n Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Factory;
use Symfony\Component\Validator\Exception\NoSuchMetadataException;
use Symfony\Component\Validat... | .
*
* @throws NoSuchMetadataException If no metadata exists for the given value
*/
public function getMetadataFor(mixed $value): MetadataInterface;
/**
* Returns whether the class is able to return metadata for the given value. | /**
* Returns the metadata for the given value | {
"filepath": "src/Symfony/Component/Validator/Mapping/Factory/MetadataFactoryInterface.php",
"language": "php",
"file_size": 957,
"cut_index": 582,
"middle_length": 52
} |
/*
* 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 Symfony\Component\Validator\Mapping;
/**
* Stores all metadata needed for va... | tadataInterface
* @see CascadingStrategy
* @see TraversalStrategy
*/
interface PropertyMetadataInterface extends MetadataInterface
{
/**
* Returns the name of the property.
*/
public function getPropertyName(): string;
/**
* | stores whether objects stored in the property
* should be validated against their class' metadata and whether traversable
* objects should be traversed or not.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @see Me | {
"filepath": "src/Symfony/Component/Validator/Mapping/PropertyMetadataInterface.php",
"language": "php",
"file_size": 1143,
"cut_index": 518,
"middle_length": 229
} |
ile that was distributed with this source code.
*/
if ('cli' !== \PHP_SAPI) {
throw new Exception('This script must be run from the command line.');
}
/*
* This script syncs IBAN formats from the upstream and updates them into IbanValidator.
*
* Usage:
* php Resources/bin/sync-iban-formats.php
*/
error_r... | g validator...\n";
updateValidatorFormats(__DIR__.'/../../Constraints/IbanValidator.php', $formats);
echo "Done.\n";
exit(0);
function updateValidatorFormats(string $validatorPath, array $formats): void
{
ksort($formats);
$formatsContent = "[\ | IBAN formats...\n";
$formats = array_merge(
(new WikipediaIbanProvider())->getIbanFormats(),
(new SwiftRegistryIbanProvider())->getIbanFormats()
);
printf("Collected %d IBAN formats\n", count($formats));
echo "Updatin | {
"filepath": "src/Symfony/Component/Validator/Resources/bin/sync-iban-formats.php",
"language": "php",
"file_size": 5695,
"cut_index": 716,
"middle_length": 229
} |
/*
* 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 Symfony\Component\Validator\Tests\Constraints;
use Symfony\Component\Validato... | o', new DummyCompoundConstraint());
$this->assertNoViolation();
}
public function testValidateWithConstraints()
{
$value = 'foo';
$constraint = new DummyCompoundConstraint();
$this->expectValidateValue(0, $val | torTest extends ConstraintValidatorTestCase
{
protected function createValidator(): CompoundValidator
{
return new CompoundValidator();
}
public function testValidValue()
{
$this->validate('fo | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/CompoundValidatorTest.php",
"language": "php",
"file_size": 1126,
"cut_index": 518,
"middle_length": 229
} |
ge.
*
* (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 Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\Constraints... | adata('a')[0]->getConstraints();
self::assertSame(42, $aConstraint->min);
self::assertSame(42, $aConstraint->max);
self::assertNull($aConstraint->divisibleBy);
[$bConstraint] = $metadata->getPropertyMetadata('b')[0]->getCon | butes()
{
$metadata = new ClassMetadata(CountDummy::class);
$loader = new AttributeLoader();
self::assertTrue($loader->loadClassMetadata($metadata));
[$aConstraint] = $metadata->getPropertyMet | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/CountTest.php",
"language": "php",
"file_size": 2064,
"cut_index": 563,
"middle_length": 229
} |
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 Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\TestCase;
use Symfony\Compo... | int] = $metadata->getPropertyMetadata('a')[0]->getConstraints();
self::assertSame(2, $aConstraint->value);
self::assertNull($aConstraint->propertyPath);
[$bConstraint] = $metadata->getPropertyMetadata('b')[0]->getConstraints();
|
public function testAttributes()
{
$metadata = new ClassMetadata(EqualToDummy::class);
$loader = new AttributeLoader();
self::assertTrue($loader->loadClassMetadata($metadata));
[$aConstra | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/EqualToTest.php",
"language": "php",
"file_size": 1743,
"cut_index": 537,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Tests\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\EqualTo;
use Symfony\Component\Validat... | use ValidComparisonToValueTrait;
protected function createValidator(): EqualToValidator
{
return new EqualToValidator();
}
protected static function createConstraint(?array $options = null): Constraint
{
if (null !== $ | es <daniel@danielholmes.org>
*/
class EqualToValidatorTest extends AbstractComparisonValidatorTestCase
{
use IcuCompatibilityTrait;
use InvalidComparisonToValueTestTrait;
use ThrowsOnInvalidStringDatesTestTrait;
| {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php",
"language": "php",
"file_size": 4124,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (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 Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCa... | lf::assertSame(ExpressionSyntaxValidator::class, $constraint->validatedBy());
}
#[DataProvider('provideServiceValidatedConstraints')]
public function testValidatedByService(ExpressionSyntax $constraint)
{
self::assertSame('my_servi | use Symfony\Component\Validator\Mapping\Loader\AttributeLoader;
class ExpressionSyntaxTest extends TestCase
{
public function testValidatedByStandardValidator()
{
$constraint = new ExpressionSyntax();
se | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/ExpressionSyntaxTest.php",
"language": "php",
"file_size": 2665,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Tests\Constraints;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use Symfony\Component\Validator\Constraints\ExpressionSyntax;
use... | guage());
}
public function testNullIsValid()
{
$this->validate(null, new ExpressionSyntax());
$this->assertNoViolation();
}
public function testEmptyStringIsValid()
{
$this->validate('', new ExpressionSyn | \StringableValue;
class ExpressionSyntaxValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator(): ExpressionSyntaxValidator
{
return new ExpressionSyntaxValidator(new ExpressionLan | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/ExpressionSyntaxValidatorTest.php",
"language": "php",
"file_size": 3259,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (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 Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\Constraints... | ta));
[$aConstraint] = $metadata->getPropertyMetadata('a')[0]->getConstraints();
self::assertSame('value == "1"', $aConstraint->expression);
self::assertSame([], $aConstraint->values);
self::assertTrue($aConstraint->negate) | oader;
class ExpressionTest extends TestCase
{
public function testAttributes()
{
$metadata = new ClassMetadata(ExpressionDummy::class);
self::assertTrue((new AttributeLoader())->loadClassMetadata($metada | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/ExpressionTest.php",
"language": "php",
"file_size": 2431,
"cut_index": 563,
"middle_length": 229
} |
ymfony\Component\Validator\Constraints\Expression;
use Symfony\Component\Validator\Constraints\ExpressionLanguageProvider;
use Symfony\Component\Validator\Constraints\ExpressionValidator;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Valida... | ion testExpressionIsEvaluatedWithNullValue()
{
$constraint = new Expression(
expression: 'false',
message: 'myMessage',
);
$this->validate(null, $constraint);
$this->buildViolation('myMessage')
| r\Tests\Fixtures\ToString;
class ExpressionValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator(): ExpressionValidator
{
return new ExpressionValidator();
}
public funct | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php",
"language": "php",
"file_size": 10766,
"cut_index": 921,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\Constraints\File;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
use Symfony\Component\Vali... | ssertSame($binaryFormat, $file->binaryFormat);
$this->assertTrue($file->__isset('maxSize'));
}
public function testMagicIsset()
{
$file = new File(maxSize: 1);
$this->assertTrue($file->__isset('maxSize'));
$thi | e
{
#[DataProvider('provideValidSizes')]
public function testMaxSize($maxSize, $bytes, $binaryFormat)
{
$file = new File(maxSize: $maxSize);
$this->assertSame($bytes, $file->maxSize);
$this->a | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/FileTest.php",
"language": "php",
"file_size": 6377,
"cut_index": 716,
"middle_length": 229
} |
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 Symfony\Component\Validator\Tests\Constraints;
use Symfony\Component\Validator\Constraints\Fil... | ssage: 'myMessage',
);
$this->validate('foobar', $constraint);
$this->buildViolation('myMessage')
->setParameter('{{ file }}', '"foobar"')
->setCode(File::NOT_FOUND_ERROR)
->assertRaised();
| $constraint = new File(
notFoundMe | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php",
"language": "php",
"file_size": 847,
"cut_index": 535,
"middle_length": 52
} |
protected $file;
protected function createValidator(): FileValidator
{
return new FileValidator();
}
protected function setUp(): void
{
parent::setUp();
$this->path = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'FileValidatorTest';
$this->file = fopen($this->path, ... | $this->assertNoViolation();
}
public function testEmptyStringIsValid()
{
$this->validate('', new File());
$this->assertNoViolation();
}
public function testExpectsStringCompatibleTypeOrFile()
{
$this- | file);
}
if (file_exists($this->path)) {
@unlink($this->path);
}
$this->file = null;
}
public function testNullIsValid()
{
$this->validate(null, new File());
| {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTestCase.php",
"language": "php",
"file_size": 24101,
"cut_index": 1331,
"middle_length": 229
} |
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 Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\TestCase;
use Symfony\Compo... | ($metadata));
[$aConstraint] = $metadata->getPropertyMetadata('a')[0]->getConstraints();
self::assertSame(2, $aConstraint->value);
self::assertNull($aConstraint->propertyPath);
[$bConstraint] = $metadata->getPropertyMetada | est extends TestCase
{
public function testAttributes()
{
$metadata = new ClassMetadata(GreaterThanOrEqualDummy::class);
$loader = new AttributeLoader();
self::assertTrue($loader->loadClassMetadata | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualTest.php",
"language": "php",
"file_size": 1831,
"cut_index": 537,
"middle_length": 229
} |
ge.
*
* (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 Symfony\Component\Validator\Tests\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator... | alueTestTrait;
use ThrowsOnInvalidStringDatesTestTrait;
use ValidComparisonToValueTrait;
protected function createValidator(): GreaterThanOrEqualValidator
{
return new GreaterThanOrEqualValidator();
}
protected static func | lmes <daniel@danielholmes.org>
*/
class GreaterThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase
{
use CompareWithNullValueAtPropertyAtTestTrait;
use IcuCompatibilityTrait;
use InvalidComparisonToV | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php",
"language": "php",
"file_size": 2886,
"cut_index": 563,
"middle_length": 229
} |
ge.
*
* (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 Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Valida... | GreaterThanOrEqualValidator();
}
protected static function createConstraint(?array $options = null): Constraint
{
return new PositiveOrZero($options);
}
public static function provideValidComparisons(): array
{
ret | ch@sensiolabs.de>
*/
class GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest extends AbstractComparisonValidatorTestCase
{
protected function createValidator(): GreaterThanOrEqualValidator
{
return new | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php",
"language": "php",
"file_size": 2785,
"cut_index": 563,
"middle_length": 229
} |
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 Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\TestCase;
use Symfony\Compo... | [$aConstraint] = $metadata->getPropertyMetadata('a')[0]->getConstraints();
self::assertSame(2, $aConstraint->value);
self::assertNull($aConstraint->propertyPath);
[$bConstraint] = $metadata->getPropertyMetadata('b')[0]->getConstr | stCase
{
public function testAttributes()
{
$metadata = new ClassMetadata(GreaterThanDummy::class);
$loader = new AttributeLoader();
self::assertTrue($loader->loadClassMetadata($metadata));
| {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/GreaterThanTest.php",
"language": "php",
"file_size": 1775,
"cut_index": 537,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Validator\Tests\Constraints;
use Symfony\Component\Clock\MockClock;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\GreaterThan;
use Symfony\Component\Validator\Constraints\GreaterThanValidator;
use Symfony\Component\... | r(): GreaterThanValidator
{
return new GreaterThanValidator();
}
protected static function createConstraint(?array $options = null): Constraint
{
if (null !== $options) {
return new GreaterThan(...$options);
| ithNullValueAtPropertyAtTestTrait;
use IcuCompatibilityTrait;
use InvalidComparisonToValueTestTrait;
use ThrowsOnInvalidStringDatesTestTrait;
use ValidComparisonToValueTrait;
protected function createValidato | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php",
"language": "php",
"file_size": 6312,
"cut_index": 716,
"middle_length": 229
} |
ge.
*
* (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 Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Valida... | protected static function createConstraint(?array $options = null): Constraint
{
return new Positive($options);
}
public static function provideValidComparisons(): array
{
return [
[2, 0],
[2.5, 0] | .de>
*/
class GreaterThanValidatorWithPositiveConstraintTest extends AbstractComparisonValidatorTestCase
{
protected function createValidator(): GreaterThanValidator
{
return new GreaterThanValidator();
}
| {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php",
"language": "php",
"file_size": 2660,
"cut_index": 563,
"middle_length": 229
} |
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 Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\TestCase;
use Symfony\Compo... | traint] = $metadata->getPropertyMetadata('a')[0]->getConstraints();
self::assertTrue($aConstraint->requireTld);
[$bConstraint] = $metadata->getPropertyMetadata('b')[0]->getConstraints();
self::assertFalse($bConstraint->requireTld); |
{
public function testAttributes()
{
$metadata = new ClassMetadata(HostnameDummy::class);
$loader = new AttributeLoader();
self::assertTrue($loader->loadClassMetadata($metadata));
[$aCons | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/HostnameTest.php",
"language": "php",
"file_size": 1605,
"cut_index": 537,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Validator\Constraints\Hostname;
use Symfony\Component\Validator\Constraints\HostnameValidator;
use Symfony\Component\Validator\Exception\UnexpectedValueExcepti... | e());
$this->assertNoViolation();
}
public function testExpectsStringCompatibleType()
{
$this->expectException(UnexpectedValueException::class);
$this->validate(new \stdClass(), new Hostname());
}
#[DataProvi | e
{
public function testNullIsValid()
{
$this->validate(null, new Hostname());
$this->assertNoViolation();
}
public function testEmptyStringIsValid()
{
$this->validate('', new Hostnam | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/HostnameValidatorTest.php",
"language": "php",
"file_size": 5494,
"cut_index": 716,
"middle_length": 229
} |
ction testNullIsValid()
{
$this->validate(null, new Iban());
$this->assertNoViolation();
}
public function testEmptyStringIsValid()
{
$this->validate('', new Iban());
$this->assertNoViolation();
}
#[DataProvider('getValidIbans')]
public function testValidI... | ->setCode(Iban::INVALID_CHARACTERS_ERROR)
->assertRaised();
}
public static function getValidIbans()
{
return [
['CH9300762011623852957'], // Switzerland without spaces
['CH93 0076 2011 6238 52 | ing $iban)
{
$this->validate($iban."\n", new Iban());
$this->buildViolation('This is not a valid International Bank Account Number (IBAN).')
->setParameter('{{ value }}', '"'.$iban."\n\"")
| {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php",
"language": "php",
"file_size": 23908,
"cut_index": 1331,
"middle_length": 229
} |
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 Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\TestCase;
use Symfony\Compo... | [$aConstraint] = $metadata->getPropertyMetadata('a')[0]->getConstraints();
self::assertSame(2, $aConstraint->value);
self::assertNull($aConstraint->propertyPath);
[$bConstraint] = $metadata->getPropertyMetadata('b')[0]->getConstr | stCase
{
public function testAttributes()
{
$metadata = new ClassMetadata(IdenticalToDummy::class);
$loader = new AttributeLoader();
self::assertTrue($loader->loadClassMetadata($metadata));
| {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/IdenticalToTest.php",
"language": "php",
"file_size": 1775,
"cut_index": 537,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Tests\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\IdenticalTo;
use Symfony\Component\Val... | tTrait;
use ValidComparisonToValueTrait;
protected function createValidator(): IdenticalToValidator
{
return new IdenticalToValidator();
}
protected static function createConstraint(?array $options = null): Constraint
{
| iel Holmes <daniel@danielholmes.org>
*/
class IdenticalToValidatorTest extends AbstractComparisonValidatorTestCase
{
use IcuCompatibilityTrait;
use InvalidComparisonToValueTestTrait;
use ThrowsOnInvalidStringDatesTes | {
"filepath": "src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php",
"language": "php",
"file_size": 4472,
"cut_index": 614,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.