Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove \DateTimeInterface reference from constraint validators #10302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions reference/constraints/Date.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
Date
====

Validates that a value is a valid date, meaning either a ``DateTime`` object
or a string (or an object that can be cast into a string) that follows a
valid YYYY-MM-DD format.
Validates that a value is a valid date, meaning a string (or an object that can be cast into a string)
that follows a valid YYYY-MM-DD format.

+----------------+--------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
Expand Down Expand Up @@ -32,6 +31,7 @@ Basic Usage
{
/**
* @Assert\Date()
* @var string A "Y-m-d" formatted value
*/
protected $birthday;
}
Expand Down Expand Up @@ -69,6 +69,11 @@ Basic Usage

class Author
{
/**
* @var string A "Y-m-d" formatted value
*/
protected $birthday;

public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('birthday', new Assert\Date());
Expand Down
11 changes: 8 additions & 3 deletions reference/constraints/DateTime.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
DateTime
========

Validates that a value is a valid "datetime", meaning either a ``DateTime``
object or a string (or an object that can be cast into a string) that follows
a specific format.
Validates that a value is a valid "datetime", meaning a string (or an object that can be cast into a string)
that follows a specific format.

+----------------+------------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
Expand Down Expand Up @@ -33,6 +32,7 @@ Basic Usage
{
/**
* @Assert\DateTime()
* @var string A "Y-m-d H:i:s" formatted value
*/
protected $createdAt;
}
Expand Down Expand Up @@ -70,6 +70,11 @@ Basic Usage

class Author
{
/**
* @var string A "Y-m-d H:i:s" formatted value
*/
protected $createdAt;

public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('createdAt', new Assert\DateTime());
Expand Down
9 changes: 7 additions & 2 deletions reference/constraints/Time.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Time
====

Validates that a value is a valid time, meaning an object implementing
``DateTimeInterface`` or a string (or an object that can be cast into a string)
Validates that a value is a valid time, meaning a string (or an object that can be cast into a string)
that follows a valid ``HH:MM:SS`` format.

+----------------+------------------------------------------------------------------------+
Expand Down Expand Up @@ -35,6 +34,7 @@ of the day when the event starts:
{
/**
* @Assert\Time()
* @var string A "H:i:s" formatted value
*/
protected $startsAt;
}
Expand Down Expand Up @@ -72,6 +72,11 @@ of the day when the event starts:

class Event
{
/**
* @var string A "H:i:s" formatted value
*/
protected $startsAt;

public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('startsAt', new Assert\Time());
Expand Down