IbanValidator accepts IBANs containing non-breaking and narrow non-breaking spacesPasswordStrengthValidator::estimateStrength() publicYaml constraint for validating YAML contenterrorPath to Unique constraintformat option to the Ulid constraint to allow accepting different ULID formatsWordCount constraintWeek constraintCompoundConstraintTestCase to ease testing Compound ConstraintsWhenValidatorrequireTld option to the Url constraint (the default value will become true in 8.0)PasswordStrengthValidatorStringable values when using the Cidr, CssColor, ExpressionSyntax and PasswordStrength constraintsMacAddress constraint*_NO_PUBLIC, *_ONLY_PRIVATE and *_ONLY_RESERVED versions to Ip constraintIp constraint versions for Cidr constraintlist and associative_array types to Type constraintCharset constraintrequireTld option to the Url constraintBic::INVALID_BANK_CODE_ERRORgetConstraint(), getCause() and __toString() to ConstraintViolationInterface__toString() to ConstraintViolationListInterfacedisableTranslation() to ConstraintViolationBuilderInterface$errorNames from all constraints, use const ERROR_NAMES instead$versions from the Ip constraint, use the VERSIONS constant insteadVALIDATION_MODE_LOOSE from Email constraint, use VALIDATION_MODE_HTML5 insteadExpressionLanguageSyntax, use ExpressionSyntax insteadAnnotationLoaderValidatorBuilder::setDoctrineAnnotationReader()ValidatorBuilder::addDefaultDoctrineAnnotationReader()ValidatorBuilder::enableAnnotationMapping(), use ValidatorBuilder::enableAttributeMapping() insteadValidatorBuilder::disableAnnotationMapping(), use ValidatorBuilder::disableAttributeMapping() insteadAnnotationLoader, use AttributeLoader insteadis_valid function to the Expression constraint, its behavior is the same as ValidatorInterface::validateversions option of the Uuid constraintconstraints option of the When constraintValidatorBuilder::setDoctrineAnnotationReader()ValidatorBuilder::addDefaultDoctrineAnnotationReader()number, finite-number and finite-float types to Type constraintwithSeconds option to the Time constraint that allows to pass time without secondsValidatorBuilder::enableAnnotationMapping(), use ValidatorBuilder::enableAttributeMapping() insteadValidatorBuilder::disableAnnotationMapping(), use ValidatorBuilder::disableAttributeMapping() insteadAnnotationLoader, use AttributeLoader insteadGroupProviderInterface to implement validation group providers outside the underlying classgetConstraint() to ConstraintViolationInterfaceUuid::TIME_BASED_VERSIONS to match that a UUID being validated embeds a timestamppattern parameter in violations of the Regex constraintNoSuspiciousCharacters constraint to validate a string is not a spoofing attemptPasswordStrength constraint to check the strength of a passwordcountUnit option to the Length constraint to allow counting the string length either by code points (like before, now the default setting Length::COUNT_CODEPOINTS), bytes (Length::COUNT_BYTES) or graphemes (Length::COUNT_GRAPHEMES)filenameMaxLength option to the File constraintexclude option to the Cascade constraintvalue_length parameter to Length constraintConstraintViolationInterface messagesEmail::VALIDATION_MODE_HTML5_ALLOW_NO_TLD with “html5-allow-no-tld” e-mail validation mode, to match with the W3C official specificationgetCause() to ConstraintViolationInterfaceWhen constraint and validatornegate option to the Expression constraint, to inverse the logic of the violation’s creationextensions option to the File constraint as an alternative to mimeTypes which checks the mime type of the file, its extension, and the consistency between themNotCompromisedPasswordValidatorfields option to the Unique constraint, to define which collection keys should be checked for uniquenessConstraint::$errorNames, use Constraint::ERROR_NAMES insteadExpressionLanguageSyntax, use ExpressionSyntax instead__toString() to ConstraintViolationInterface & ConstraintViolationListInterfacematch option to the Choice constraintallowEmptyString option from the Length constraintNumberConstraintTrait traitValidatorBuilder::enableAnnotationMapping() does not accept a Doctrine annotation reader anymoreValidatorBuilder::enableAnnotationMapping() won’t automatically setup a Doctrine annotation reader anymoreCidr constraint to validate CIDR notationsCssColor constraint to validate CSS colorsConstraintViolationList::createFromMessage()Count and Length constraints with “exactly” option enablednormalizer option to the Unique constraintValidation::createIsValidCallable() that returns true/false instead of throwing exceptionsCascade constraint to ease validating nested typed object propertiesdeprecated the allowEmptyString option of the Length constraint
Before:
```php use Symfony\Component\Validator\Constraints as Assert;
/**
After:
```php use Symfony\Component\Validator\Constraints as Assert;
/**
Isin constraint and validatorULID constraint and validatorUuid constraintNumberConstraintTrait traitValidatorBuilder::enableAnnotationMapping(), pass true as first parameter and additionally call setDoctrineAnnotationReader() or addDefaultDoctrineAnnotationReader() to set up the annotation readerAtLeastOneOf constraint that is considered to be valid if at least one of the nested constraints is validHostname constraint and validatoralpha3 option to the Country and Language constraintsCompound constraintSequentially constraint, to sequentially validate a set of constraints (any violation raised will prevent further validation of the nested constraints)divisibleBy option to the Count constraintExpressionLanguageSyntax constraintExpressionLanguage instance or null must be passed as the first argument of ExpressionValidator::__construct()checkDNS and dnsMessage options of the Url constraintcheckMX, checkHost and strict options of the Email constraint\DateTimeInterface in DateTimeValidator, DateValidator and TimeValidatorBic, Country, Currency, Language and Locale constraints without symfony/intlEmail constraint without egulias/email-validatorExpression constraint without symfony/expression-languagecanonicalize option of Locale constraint to trueValidatorBuilderInterfaceConstraintViolation is not allowedLength::$allowEmptyString to false and made it optionalSymfony\Component\Validator\Mapping\Cache\CacheInterface in favor of PSR-6.ValidatorBuilder::setMetadataCache, use ValidatorBuilder::setMappingCache instead.$classValidatorRegexp value in PropertyInfoLoader::__construct will not enable auto-mapping for all classes anymore, use '{.*}' instead.EnableAutoMapping and DisableAutoMapping constraints to enable or disable auto mapping for class or a propertystring as the code of a ConstraintViolation is deprecated, a string type-hint will
be added to the constructor of the ConstraintViolation class and to the ConstraintViolationBuilder::setCode()
method in 5.0ExpressionLanguage instance as the second argument of ExpressionValidator::__construct(). Pass it as the first argument instead.compared_value_path parameter in violations when using any
comparison constraint with the propertyPath option.TypeValidatorallowEmptyString option to the Length constraint to allow rejecting empty strings when min is set, by setting it to false.minPropertyPath and maxPropertyPath options
to Range constraint in order to get the value to compare
from an array or objectmin_limit_path and max_limit_path parameters in violations when using
Range constraint with respectively the minPropertyPath and
maxPropertyPath optionsnotInRangeMessage option to the Range constraint that will
be used in the violation builder when both min and max are not nullConstraintValidatorTestCase::setUp() and ConstraintValidatorTestCase::tearDown() without the void return-type is deprecated.Symfony\Component\Validator\Mapping\Cache\CacheInterface in favor of PSR-6.ValidatorBuilder::setMetadataCache, use ValidatorBuilder::setMappingCache instead.ValidatorDataCollector class as @final.Timezone constraintNotCompromisedPassword constraintiban and ibanPropertyPath to Bic constraintCardSchemeValidatorallowNull to NotBlank constraintJson constraintUnique constraintnormalizer option to the string constraints and to the NotBlank constraintPositive constraintPositiveOrZero constraintNegative constraintNegativeOrZero constraintUnexpectedValueException that can be thrown by constraint validators, these exceptions are caught by
the validator and are converted into constraint violationsDivisibleBy constraintsymfony/translation by using Symfony\Contracts\Translation\TranslatorInterfaceValidatorBuilderInterfaceValidatorBuilder::setTranslator() finalformat the default option in DateTime constraint\DateTimeInterface in DateTimeValidator, DateValidator and TimeValidator.Bic, Country, Currency, Language and Locale constraints without symfony/intlEmail constraint without egulias/email-validatorExpression constraint without symfony/expression-languagecheckDNS and dnsMessage options of the Url constraint.values option to the Expression constraintLocale constraint without setting true at “canonicalize” option, which will be the default value in 5.0strict option of the Choice constraint to anything but true
is not supported anymore.DateTimeValidator::PATTERN constantAbstractConstraintValidatorTest classcheckDNS option of the Url constraint to trueValid constraintstrict option of the Choice constraint to true is
deprecated and will throw an exception in Symfony 4.0checkDNS option of the Url constraint to true is deprecated in favor of
the Url::CHECK_DNS_TYPE_* constants values and will throw an exception in Symfony 4.0Image constraint via minPixels and maxPixelsAddValidatorInitializersPassAddConstraintValidatorsPassContainerConstraintValidatorFactoryTests\Constraints\AbstractConstraintValidatorTest in favor of Test\ConstraintValidatorTestCaseDateTimeValidator::PATTERN constantformat option to the DateTime constraintDefaultTranslator in favor of Symfony\Component\Translation\IdentityTranslatorIs-prefixed equivalentFileValidator disallow empty filesUserPasswordValidator source message changeExecutionContextInterface::setConstraint()ConstraintViolation::getConstraint()ExpressionValidator will now evaluate the Expression even when the property value is null or an empty stringClassMetadata::hasMemberMetadatas()ClassMetadata::getMemberMetadatas()ClassMetadata::addMemberMetadata()Mapping\MetadataInterface::getConstraints()ConstraintViolationBuilderInterface::setCause()ApcCache in favor of DoctrineCacheDoctrineCache to adapt any Doctrine cacheGroupSequence now implements ArrayAccess, Countable and TraversableClassMetadata::getGroupSequence() to return a GroupSequence instance instead of an arrayCallback can now be put onto properties (useful when you pass a closure to the constraint)ClassBasedInterfaceMetadataInterfacePropertyMetadataInterfacePropertyMetadataContainerInterfaceMapping\ElementMetadataMapping\MetadataInterfaceMapping\ClassMetadataInterfaceMapping\PropertyMetadataInterfaceMapping\GenericMetadataMapping\CascadingStrategyMapping\TraversalStrategyMapping\ClassMetadata::accept()Mapping\MemberMetadata::accept()Mapping\ClassMetadata::setGroupSequence()MetadataFactoryInterfaceMapping\BlackholeMetadataFactoryMapping\ClassMetadataFactoryMapping\Factory\MetadataFactoryInterfaceMapping\Factory\BlackHoleMetadataFactoryMapping\Factory\LazyLoadingMetadataFactoryExecutionContextInterfaceExecutionContextGlobalExecutionContextInterfaceContext\ExecutionContextInterfaceContext\ExecutionContextContext\ExecutionContextFactoryInterfaceContext\ExecutionContextFactoryValidatorInterfaceValidatorValidationVisitorInterfaceValidationVisitorValidator\ValidatorInterfaceValidator\RecursiveValidatorValidator\ContextualValidatorInterfaceValidator\RecursiveContextualValidatorViolation\ConstraintViolationBuilderInterfaceViolation\ConstraintViolationBuilderConstraintViolation::getParameters()ConstraintViolation::getPlural()Constraints\Traverse$deep property in Constraints\ValidValidatorBuilderInterface::setApiVersion()Validation::API_VERSION_2_4Validation::API_VERSION_2_5Exception\OutOfBoundsExceptionException\UnsupportedMetadataExceptionException\ValidatorException extend Exception\RuntimeExceptionUtil\PropertyPathValidatorBuilder::setPropertyAccessor()validate and validateValue on Validator\Context\ExecutionContext use getValidator() together with inContext() insteadminRatio, maxRatio, allowSquare, allowLandscape, and allowPortrait to Image validatorOptional and Required to the
Symfony\Component\Validator\Constraints\ namespace and deprecated the original
classes.Validator to ValidatorInterfaceConstraintViolation to the new ConstraintViolationInterfaceConstraintViolationList to the new ConstraintViolationListInterfaceExecutionContext to the new ExecutionContextInterfaceConstraintValidatorInterface::initialize is now type hinted against ExecutionContextInterface instead of ExecutionContextValidator from protected to privateClassMetadataFactoryInterface in favor of the new MetadataFactoryInterfaceClassMetadataFactory::getClassMetadata in favor of getMetadataForMetadataInterface, PropertyMetadataInterface, ClassBasedInterface and PropertyMetadataContainerInterfaceGraphWalker in favor of the new ValidationVisitorInterfaceExecutionContext::addViolationAtPathExecutionContext::addViolationAtSubPath in favor of ExecutionContextInterface::addViolationAtExecutionContext::getCurrentClass in favor of ExecutionContextInterface::getClassNameExecutionContext::getCurrentProperty in favor of ExecutionContextInterface::getPropertyNameExecutionContext::getCurrentValue in favor of ExecutionContextInterface::getValueExecutionContext::getGraphWalker in favor of ExecutionContextInterface::validate and ExecutionContextInterface::validateValueValidatorInterface::validateValue to accept arrays of constraintsValidatorInterface::getMetadataFactory to return a MetadataFactoryInterface instead of a ClassMetadataFactoryInterfaceClassMetadataFactoryInterface type hint from ValidatorBuilderInterface::setMetadataFactory.
As of Symfony 2.3, this method will be typed against MetadataFactoryInterface instead.traverse and deep in the Valid constraint and in GraphWalker::walkReference
are ignored for arrays now. Arrays are always traversed recursively.$message in the constructor of ConstraintViolation$translator and $translationDomain in the constructor of ExecutionContext$translator and $translationDomain in the constructor of GraphWalker$translator and $translationDomain in the constructor of ValidationVisitor$translator and $translationDomain in the constructor of ValidatorsetTranslator() and setTranslationDomain() to ValidatorBuilderInterfacectype_* assertions in TypeValidatorextraFieldsMessage and missingFieldsMessage
in Collection constraintsetMessage, getMessageTemplate and
getMessageParametersisValid has been renamed to
validate, its return value was dropped. ConstraintValidator still contains
isValid for BCValid are not traversed
recursively anymore by default. Valid contains a new property deep
which enables the BC behavior.