Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feature #17553 [Validator] Added a format option to the DateTime cons…
…traint. (dosten) This PR was merged into the 3.1-dev branch. Discussion ---------- [Validator] Added a format option to the DateTime constraint. | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #14521 | License | MIT This PR adds a `format` option to the `DateTime` constraint, this allows to validate dates in custom formats, for example: ```php use Symfony\Component\Validator\Constraints\DateTime; use Symfony\Component\Validator\Validation; $validator = Validation::createValidator(); $validator->validate('December 31, 1999', new DateTime(['format' => 'F d, Y'])); $validator->validate('01:02:03', new DateTime(['format' => 'H:i:s'])); $validator->validate('2010/01/01 01:02', new DateTime(['format' => 'Y/m/d H:i'])); ``` As you can see this new option allows to use the `DateTime` constraint to validate dates and times, so, maybe the `Date` and `Time` constraints can be deprecated in this PR. Commits ------- 9e94c9f Added a format option to the DateTime constraint.
- Loading branch information
Showing
6 changed files
with
81 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters