Examples of validation

In this article I try to combine few examples of validation on yii framework.
1) Check that date in mm/dd/yyyy format will in the future:

1
2
array('startDate, endDate', 'date', 'format' => 'MM/dd/yyyy'),
array('startDate, endDate', 'compare', 'compareValue' => date('m/d/Y'), 'operator' => '>=', 'message'=>'{attribute} must be later or equal than Now.'),

2) Validate time in “g:i a” format:

1
array('startTime, endTime', 'date', 'allowEmpty' => true, 'format' => 'M:m a'),

Continue reading