-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Closed
Labels
Description
Hi there,
At work we wanted to check if a date (in a form) was greater than "now". The problem was that we were using annotations in our entity for the validation and (apparently) there is no "simple" way to do so.
The solutions which came to my mind were:
- Use the "assert greater than" validator directly in the form type (
$builder->add('foo', 'bar', array('constraints' => new \DateTime())) - Use the annotation
@Assert\Trueon my date field and implement anisDateValidmethod - Create a dedicated annotation
- Create an
@DateTimeannotation which would extends from\DateTimeand could be used everywhere (in my case :@Assert\GreaterThan(value = @DateTime))
I've chosen to implement the latest of my proposal (@DateTime), it works well (IMO it is flexible, clean and reusable) and I think it could be a very good idea to implement it in symfony.
What do you think about it?
If you feel like it, I can share my work.