Time¶
Validates that a value is a valid time, meaning either a DateTime
object
or a string (or an object that can be cast into a string) that follows
a valid “HH:MM:SS” format.
Applies to | property or method |
Options | |
Class | Symfony\Component\Validator\Constraints\Time |
Validator | Symfony\Component\Validator\Constraints\TimeValidator |
Basic Usage¶
Suppose you have an Event class, with a startAt
field that is the time
of the day when the event starts:
- YAML
# src/Acme/EventBundle/Resources/config/validation.yml Acme\EventBundle\Entity\Event: properties: startsAt: - Time: ~
- Annotations
// src/Acme/EventBundle/Entity/Event.php namespace Acme\EventBundle\Entity; use Symfony\Component\Validator\Constraints as Assert; class Event { /** * @Assert\Time() */ protected $startsAt; }