25 KiB
CHANGELOG
7.3
-
Add the
filenameCharsetandfilenameCountUnitoptions to theFileconstraint -
Deprecate defining custom constraints not supporting named arguments
Before:
use Symfony\Component\Validator\Constraint; class CustomConstraint extends Constraint { public function __construct(array $options) { // ... } }After:
use Symfony\Component\Validator\Attribute\HasNamedArguments; use Symfony\Component\Validator\Constraint; class CustomConstraint extends Constraint { #[HasNamedArguments] public function __construct($option1, $option2, $groups, $payload) { // ... } } -
Deprecate passing an array of options to the constructors of the constraint classes, pass each option as a dedicated argument instead
Before:
new NotNull([ 'groups' => ['foo', 'bar'], 'message' => 'a custom constraint violation message', ])After:
new NotNull( groups: ['foo', 'bar'], message: 'a custom constraint violation message', ) -
Add support for ratio checks for SVG files to the
Imageconstraint -
Add support for the
otherwiseoption in theWhenconstraint -
Add support for multiple fields containing nested constraints in
Compositeconstraints -
Add the
stopOnFirstErroroption to theUniqueconstraint to validate all elements -
Add support for closures in the
Whenconstraint
7.2
IbanValidatoraccepts IBANs containing non-breaking and narrow non-breaking spaces- Make
PasswordStrengthValidator::estimateStrength()public - Add the
Yamlconstraint for validating YAML content - Add
errorPathto Unique constraint - Add the
formatoption to theUlidconstraint to allow accepting different ULID formats - Add the
WordCountconstraint - Add the
Weekconstraint - Add
CompoundConstraintTestCaseto ease testing Compound Constraints - Add context variable to
WhenValidator - Add
formatparameter toDateTimeconstraint violation message
7.1
- Deprecate not passing a value for the
requireTldoption to theUrlconstraint (the default value will becometruein 8.0) - Add the calculated strength to violations in
PasswordStrengthValidator - Add support for
Stringablevalues when using theCidr,CssColor,ExpressionSyntaxandPasswordStrengthconstraints - Add
MacAddressconstraint - Add
*_NO_PUBLIC,*_ONLY_PRIVATEand*_ONLY_RESERVEDversions toIpconstraint - Possibility to use all
Ipconstraint versions forCidrconstraint - Add
listandassociative_arraytypes toTypeconstraint - Add the
Charsetconstraint - Add the
requireTldoption to theUrlconstraint - Deprecate
Bic::INVALID_BANK_CODE_ERROR
7.0
- Add methods
getConstraint(),getCause()and__toString()toConstraintViolationInterface - Add method
__toString()toConstraintViolationListInterface - Add method
disableTranslation()toConstraintViolationBuilderInterface - Remove static property
$errorNamesfrom all constraints, use constERROR_NAMESinstead - Remove static property
$versionsfrom theIpconstraint, use theVERSIONSconstant instead - Remove
VALIDATION_MODE_LOOSEfromEmailconstraint, useVALIDATION_MODE_HTML5instead - Remove constraint
ExpressionLanguageSyntax, useExpressionSyntaxinstead - Remove Doctrine annotations support in favor of native attributes
- Remove the annotation reader parameter from the constructor signature of
AnnotationLoader - Remove
ValidatorBuilder::setDoctrineAnnotationReader() - Remove
ValidatorBuilder::addDefaultDoctrineAnnotationReader() - Remove
ValidatorBuilder::enableAnnotationMapping(), useValidatorBuilder::enableAttributeMapping()instead - Remove
ValidatorBuilder::disableAnnotationMapping(), useValidatorBuilder::disableAttributeMapping()instead - Remove
AnnotationLoader, useAttributeLoaderinstead
6.4
- Add
is_validfunction to theExpressionconstraint, its behavior is the same asValidatorInterface::validate - Allow single integer for the
versionsoption of theUuidconstraint - Allow single constraint to be passed to the
constraintsoption of theWhenconstraint - Deprecate Doctrine annotations support in favor of native attributes
- Deprecate
ValidatorBuilder::setDoctrineAnnotationReader() - Deprecate
ValidatorBuilder::addDefaultDoctrineAnnotationReader() - Add
number,finite-numberandfinite-floattypes toTypeconstraint - Add the
withSecondsoption to theTimeconstraint that allows to pass time without seconds - Deprecate
ValidatorBuilder::enableAnnotationMapping(), useValidatorBuilder::enableAttributeMapping()instead - Deprecate
ValidatorBuilder::disableAnnotationMapping(), useValidatorBuilder::disableAttributeMapping()instead - Deprecate
AnnotationLoader, useAttributeLoaderinstead - Add
GroupProviderInterfaceto implement validation group providers outside the underlying class
6.3
- Add method
getConstraint()toConstraintViolationInterface - Add
Uuid::TIME_BASED_VERSIONSto match that a UUID being validated embeds a timestamp - Add the
patternparameter in violations of theRegexconstraint - Add a
NoSuspiciousCharactersconstraint to validate a string is not a spoofing attempt - Add a
PasswordStrengthconstraint to check the strength of a password - Add the
countUnitoption to theLengthconstraint to allow counting the string length either by code points (like before, now the default settingLength::COUNT_CODEPOINTS), bytes (Length::COUNT_BYTES) or graphemes (Length::COUNT_GRAPHEMES) - Add the
filenameMaxLengthoption to theFileconstraint - Add the
excludeoption to theCascadeconstraint - Add the
value_lengthparameter toLengthconstraint - Allow to disable the translation domain for
ConstraintViolationInterfacemessages
6.2
- Add option
Email::VALIDATION_MODE_HTML5_ALLOW_NO_TLDwith "html5-allow-no-tld" e-mail validation mode, to match with the W3C official specification - Add method
getCause()toConstraintViolationInterface - Add the
Whenconstraint and validator - Deprecate the "loose" e-mail validation mode, use "html5" instead
- Add the
negateoption to theExpressionconstraint, to inverse the logic of the violation's creation - Add the
extensionsoption to theFileconstraint as an alternative tomimeTypeswhich checks the mime type of the file, its extension, and the consistency between them - Add padding for enhanced privacy to the
NotCompromisedPasswordValidator
6.1
- Add the
fieldsoption to theUniqueconstraint, to define which collection keys should be checked for uniqueness - Deprecate
Constraint::$errorNames, useConstraint::ERROR_NAMESinstead - Deprecate constraint
ExpressionLanguageSyntax, useExpressionSyntaxinstead - Add method
__toString()toConstraintViolationInterface&ConstraintViolationListInterface - Allow creating constraints with required arguments
- Add the
matchoption to theChoiceconstraint
6.0
- Remove the
allowEmptyStringoption from theLengthconstraint - Remove the
NumberConstraintTraittrait ValidatorBuilder::enableAnnotationMapping()does not accept a Doctrine annotation reader anymoreValidatorBuilder::enableAnnotationMapping()won't automatically setup a Doctrine annotation reader anymore
5.4
- Add a
Cidrconstraint to validate CIDR notations - Add a
CssColorconstraint to validate CSS colors - Add support for
ConstraintViolationList::createFromMessage() - Add error's uid to
CountandLengthconstraints with "exactly" option enabled
5.3
- Add the
normalizeroption to theUniqueconstraint - Add
Validation::createIsValidCallable()that returns true/false instead of throwing exceptions
5.2.0
-
added a
Cascadeconstraint to ease validating nested typed object properties -
deprecated the
allowEmptyStringoption of theLengthconstraintBefore:
use Symfony\Component\Validator\Constraints as Assert; /** * @Assert\Length(min=5, allowEmptyString=true) */After:
use Symfony\Component\Validator\Constraints as Assert; /** * @Assert\AtLeastOneOf({ * @Assert\Blank(), * @Assert\Length(min=5) * }) */ -
added the
Isinconstraint and validator -
added the
ULIDconstraint and validator -
added support for UUIDv6 in
Uuidconstraint -
enabled the validator to load constraints from PHP attributes
-
deprecated the
NumberConstraintTraittrait -
deprecated setting or creating a Doctrine annotation reader via
ValidatorBuilder::enableAnnotationMapping(), passtrueas first parameter and additionally callsetDoctrineAnnotationReader()oraddDefaultDoctrineAnnotationReader()to set up the annotation reader
5.1.0
- Add
AtLeastOneOfconstraint that is considered to be valid if at least one of the nested constraints is valid - added the
Hostnameconstraint and validator - added the
alpha3option to theCountryandLanguageconstraints - allow to define a reusable set of constraints by extending the
Compoundconstraint - added
Sequentiallyconstraint, to sequentially validate a set of constraints (any violation raised will prevent further validation of the nested constraints) - added the
divisibleByoption to theCountconstraint - added the
ExpressionLanguageSyntaxconstraint
5.0.0
- an
ExpressionLanguageinstance or null must be passed as the first argument ofExpressionValidator::__construct() - removed the
checkDNSanddnsMessageoptions of theUrlconstraint - removed the
checkMX,checkHostandstrictoptions of theEmailconstraint - removed support for validating instances of
\DateTimeInterfaceinDateTimeValidator,DateValidatorandTimeValidator - removed support for using the
Bic,Country,Currency,LanguageandLocaleconstraints withoutsymfony/intl - removed support for using the
Emailconstraint withoutegulias/email-validator - removed support for using the
Expressionconstraint withoutsymfony/expression-language - changed default value of
canonicalizeoption ofLocaleconstraint totrue - removed
ValidatorBuilderInterface - passing a null message when instantiating a
ConstraintViolationis not allowed - changed the default value of
Length::$allowEmptyStringtofalseand made it optional - removed
Symfony\Component\Validator\Mapping\Cache\CacheInterfacein favor of PSR-6. - removed
ValidatorBuilder::setMetadataCache, useValidatorBuilder::setMappingCacheinstead.
4.4.0
- [BC BREAK] using null as
$classValidatorRegexpvalue inPropertyInfoLoader::__constructwill not enable auto-mapping for all classes anymore, use'{.*}'instead. - added
EnableAutoMappingandDisableAutoMappingconstraints to enable or disable auto mapping for class or a property - using anything else than a
stringas the code of aConstraintViolationis deprecated, astringtype-hint will be added to the constructor of theConstraintViolationclass and to theConstraintViolationBuilder::setCode()method in 5.0 - deprecated passing an
ExpressionLanguageinstance as the second argument ofExpressionValidator::__construct(). Pass it as the first argument instead. - added the
compared_value_pathparameter in violations when using any comparison constraint with thepropertyPathoption. - added support for checking an array of types in
TypeValidator - added a new
allowEmptyStringoption to theLengthconstraint to allow rejecting empty strings whenminis set, by setting it tofalse. - Added new
minPropertyPathandmaxPropertyPathoptions toRangeconstraint in order to get the value to compare from an array or object - added the
min_limit_pathandmax_limit_pathparameters in violations when usingRangeconstraint with respectively theminPropertyPathandmaxPropertyPathoptions - added a new
notInRangeMessageoption to theRangeconstraint that will be used in the violation builder when bothminandmaxare not null - added ability to use stringable objects as violation messages
- Overriding the methods
ConstraintValidatorTestCase::setUp()andConstraintValidatorTestCase::tearDown()without thevoidreturn-type is deprecated. - deprecated
Symfony\Component\Validator\Mapping\Cache\CacheInterfacein favor of PSR-6. - deprecated
ValidatorBuilder::setMetadataCache, useValidatorBuilder::setMappingCacheinstead. - Marked the
ValidatorDataCollectorclass as@final.
4.3.0
- added
Timezoneconstraint - added
NotCompromisedPasswordconstraint - added options
ibanandibanPropertyPathto Bic constraint - added UATP cards support to
CardSchemeValidator - added option
allowNullto NotBlank constraint - added
Jsonconstraint - added
Uniqueconstraint - added a new
normalizeroption to the string constraints and to theNotBlankconstraint - added
Positiveconstraint - added
PositiveOrZeroconstraint - added
Negativeconstraint - added
NegativeOrZeroconstraint
4.2.0
- added a new
UnexpectedValueExceptionthat can be thrown by constraint validators, these exceptions are caught by the validator and are converted into constraint violations - added
DivisibleByconstraint - decoupled from
symfony/translationby usingSymfony\Contracts\Translation\TranslatorInterface - deprecated
ValidatorBuilderInterface - made
ValidatorBuilder::setTranslator()final - marked
formatthe default option inDateTimeconstraint - deprecated validating instances of
\DateTimeInterfaceinDateTimeValidator,DateValidatorandTimeValidator. - deprecated using the
Bic,Country,Currency,LanguageandLocaleconstraints withoutsymfony/intl - deprecated using the
Emailconstraint withoutegulias/email-validator - deprecated using the
Expressionconstraint withoutsymfony/expression-language
4.1.0
- Deprecated the
checkDNSanddnsMessageoptions of theUrlconstraint. - added a
valuesoption to theExpressionconstraint - Deprecated use of
Localeconstraint without settingtrueat "canonicalize" option, which will be the default value in 5.0
4.0.0
- Setting the
strictoption of theChoiceconstraint to anything buttrueis not supported anymore. - removed the
DateTimeValidator::PATTERNconstant - removed the
AbstractConstraintValidatorTestclass - removed support for setting the
checkDNSoption of theUrlconstraint totrue
3.4.0
- added support for validation groups to the
Validconstraint - not setting the
strictoption of theChoiceconstraint totrueis deprecated and will throw an exception in Symfony 4.0 - setting the
checkDNSoption of theUrlconstraint totrueis deprecated in favor of theUrl::CHECK_DNS_TYPE_*constants values and will throw an exception in Symfony 4.0 - added min/max amount of pixels check to
Imageconstraint viaminPixelsandmaxPixels - added a new "propertyPath" option to comparison constraints in order to get the value to compare from an array or object
3.3.0
- added
AddValidatorInitializersPass - added
AddConstraintValidatorsPass - added
ContainerConstraintValidatorFactory
3.2.0
- deprecated
Tests\Constraints\AbstractConstraintValidatorTestin favor ofTest\ConstraintValidatorTestCase - added support for PHP constants in YAML configuration files
3.1.0
- deprecated
DateTimeValidator::PATTERNconstant - added a
formatoption to theDateTimeconstraint
2.8.0
- added the BIC (SWIFT-Code) validator
2.7.0
- deprecated
DefaultTranslatorin favor ofSymfony\Component\Translation\IdentityTranslator - deprecated PHP7-incompatible constraints (Null, True, False) and related validators (NullValidator, TrueValidator, FalseValidator) in favor of their
Is-prefixed equivalent
2.6.0
- [BC BREAK]
FileValidatordisallow empty files - [BC BREAK]
UserPasswordValidatorsource message change - [BC BREAK] added internal
ExecutionContextInterface::setConstraint() - added
ConstraintViolation::getConstraint() - [BC BREAK] The
ExpressionValidatorwill now evaluate the Expression even when the property value is null or an empty string - deprecated
ClassMetadata::hasMemberMetadatas() - deprecated
ClassMetadata::getMemberMetadatas() - deprecated
ClassMetadata::addMemberMetadata() - [BC BREAK] added
Mapping\MetadataInterface::getConstraints() - added generic "payload" option to all constraints for attaching domain-specific data
- [BC BREAK] added
ConstraintViolationBuilderInterface::setCause()
2.5.0
- deprecated
ApcCachein favor ofDoctrineCache - added
DoctrineCacheto adapt any Doctrine cache GroupSequencenow implementsArrayAccess,CountableandTraversable- [BC BREAK] changed
ClassMetadata::getGroupSequence()to return aGroupSequenceinstance instead of an array Callbackcan now be put onto properties (useful when you pass a closure to the constraint)- deprecated
ClassBasedInterface - deprecated
MetadataInterface - deprecated
PropertyMetadataInterface - deprecated
PropertyMetadataContainerInterface - deprecated
Mapping\ElementMetadata - added
Mapping\MetadataInterface - added
Mapping\ClassMetadataInterface - added
Mapping\PropertyMetadataInterface - added
Mapping\GenericMetadata - added
Mapping\CascadingStrategy - added
Mapping\TraversalStrategy - deprecated
Mapping\ClassMetadata::accept() - deprecated
Mapping\MemberMetadata::accept() - removed array type hint of
Mapping\ClassMetadata::setGroupSequence() - deprecated
MetadataFactoryInterface - deprecated
Mapping\BlackholeMetadataFactory - deprecated
Mapping\ClassMetadataFactory - added
Mapping\Factory\MetadataFactoryInterface - added
Mapping\Factory\BlackHoleMetadataFactory - added
Mapping\Factory\LazyLoadingMetadataFactory - deprecated
ExecutionContextInterface - deprecated
ExecutionContext - deprecated
GlobalExecutionContextInterface - added
Context\ExecutionContextInterface - added
Context\ExecutionContext - added
Context\ExecutionContextFactoryInterface - added
Context\ExecutionContextFactory - deprecated
ValidatorInterface - deprecated
Validator - deprecated
ValidationVisitorInterface - deprecated
ValidationVisitor - added
Validator\ValidatorInterface - added
Validator\RecursiveValidator - added
Validator\ContextualValidatorInterface - added
Validator\RecursiveContextualValidator - added
Violation\ConstraintViolationBuilderInterface - added
Violation\ConstraintViolationBuilder - added
ConstraintViolation::getParameters() - added
ConstraintViolation::getPlural() - added
Constraints\Traverse - deprecated
$deepproperty inConstraints\Valid - added
ValidatorBuilderInterface::setApiVersion() - added
Validation::API_VERSION_2_4 - added
Validation::API_VERSION_2_5 - added
Exception\OutOfBoundsException - added
Exception\UnsupportedMetadataException - made
Exception\ValidatorExceptionextendException\RuntimeException - added
Util\PropertyPath - made the PropertyAccess component an optional dependency
- deprecated
ValidatorBuilder::setPropertyAccessor() - deprecated
validateandvalidateValueonValidator\Context\ExecutionContextusegetValidator()together withinContext()instead
2.4.0
- added a constraint the uses the expression language
- added
minRatio,maxRatio,allowSquare,allowLandscape, andallowPortraitto Image validator
2.3.29
- fixed compatibility with PHP7 and up by introducing new constraints (IsNull, IsTrue, IsFalse) and related validators (IsNullValidator, IsTrueValidator, IsFalseValidator)
2.3.0
- added the ISBN, ISSN, and IBAN validators
- copied the constraints
OptionalandRequiredto theSymfony\Component\Validator\Constraints\namespace and deprecated the original classes. - added comparison validators (EqualTo, NotEqualTo, LessThan, LessThanOrEqualTo, GreaterThan, GreaterThanOrEqualTo, IdenticalTo, NotIdenticalTo)
2.2.0
- added a CardScheme validator
- added a Luhn validator
- moved @api-tags from
ValidatortoValidatorInterface - moved @api-tags from
ConstraintViolationto the newConstraintViolationInterface - moved @api-tags from
ConstraintViolationListto the newConstraintViolationListInterface - moved @api-tags from
ExecutionContextto the newExecutionContextInterface - [BC BREAK]
ConstraintValidatorInterface::initializeis now type hinted againstExecutionContextInterfaceinstead ofExecutionContext - [BC BREAK] changed the visibility of the properties in
Validatorfrom protected to private - deprecated
ClassMetadataFactoryInterfacein favor of the newMetadataFactoryInterface - deprecated
ClassMetadataFactory::getClassMetadatain favor ofgetMetadataFor - created
MetadataInterface,PropertyMetadataInterface,ClassBasedInterfaceandPropertyMetadataContainerInterface - deprecated
GraphWalkerin favor of the newValidationVisitorInterface - deprecated
ExecutionContext::addViolationAtPath - deprecated
ExecutionContext::addViolationAtSubPathin favor ofExecutionContextInterface::addViolationAt - deprecated
ExecutionContext::getCurrentClassin favor ofExecutionContextInterface::getClassName - deprecated
ExecutionContext::getCurrentPropertyin favor ofExecutionContextInterface::getPropertyName - deprecated
ExecutionContext::getCurrentValuein favor ofExecutionContextInterface::getValue - deprecated
ExecutionContext::getGraphWalkerin favor ofExecutionContextInterface::validateandExecutionContextInterface::validateValue - improved
ValidatorInterface::validateValueto accept arrays of constraints - changed
ValidatorInterface::getMetadataFactoryto return aMetadataFactoryInterfaceinstead of aClassMetadataFactoryInterface - removed
ClassMetadataFactoryInterfacetype hint fromValidatorBuilderInterface::setMetadataFactory. As of Symfony 2.3, this method will be typed againstMetadataFactoryInterfaceinstead. - [BC BREAK] the switches
traverseanddeepin theValidconstraint and inGraphWalker::walkReferenceare ignored for arrays now. Arrays are always traversed recursively. - added dependency to Translation component
- violation messages are now translated with a TranslatorInterface implementation
- [BC BREAK] inserted argument
$messagein the constructor ofConstraintViolation - [BC BREAK] inserted arguments
$translatorand$translationDomainin the constructor ofExecutionContext - [BC BREAK] inserted arguments
$translatorand$translationDomainin the constructor ofGraphWalker - [BC BREAK] inserted arguments
$translatorand$translationDomainin the constructor ofValidationVisitor - [BC BREAK] inserted arguments
$translatorand$translationDomainin the constructor ofValidator - [BC BREAK] added
setTranslator()andsetTranslationDomain()toValidatorBuilderInterface - improved the Validator to support pluralized messages by default
- [BC BREAK] changed the source of all pluralized messages in the translation files to the pluralized version
- added ExceptionInterface, BadMethodCallException and InvalidArgumentException
2.1.0
- added support for
ctype_*assertions inTypeValidator - improved the ImageValidator with min width, max width, min height, and max height constraints
- added support for MIME with wildcard in FileValidator
- changed Collection validator to add "missing" and "extra" errors to individual fields
- changed default value for
extraFieldsMessageandmissingFieldsMessagein Collection constraint - made ExecutionContext immutable
- deprecated Constraint methods
setMessage,getMessageTemplateandgetMessageParameters - added support for dynamic group sequences with the GroupSequenceProvider pattern
- [BC BREAK] ConstraintValidatorInterface method
isValidhas been renamed tovalidate, its return value was dropped. ConstraintValidator still containsisValidfor BC - [BC BREAK] collections in fields annotated with
Validare not traversed recursively anymore by default.Validcontains a new propertydeepwhich enables the BC behavior. - added Count constraint
- added Length constraint
- added Range constraint
- deprecated the Min and Max constraints
- deprecated the MinLength and MaxLength constraints
- added Validation and ValidatorBuilderInterface
- deprecated ValidatorContext, ValidatorContextInterface and ValidatorFactory