public function validateAttribute($object, $attribute) { if (parent::validateAttribute($object, $attribute)) { if ($this->validateValue($object->{$attribute})) { $this->addError($object, $attribute, $object->getAttributeLabel($attribute) . ' cannot be in the past.'); } } }
public function validateAttribute($object, $attribute) { if (parent::validateAttribute($object, $attribute)) { if (strtotime($object->{$attribute}) > strtotime(date('Y-m-d H:i:s'))) { $this->addError($object, $attribute, $object->getAttributeLabel($attribute) . ' cannot be in the future.'); } } }
/** * checks if the given attribute on the element is today or in the future. * * @param string $attribute * @param array $params */ public function todayOrFutureValidation($attribute, $params) { $min_date = $this->id ? date('Y-m-d', strtotime($this->created_date)) : date('Y-m-d'); if (!@$params['message']) { $params['message'] = '{attribute} cannot be in the past'; } $params['{attribute}'] = $this->getAttributeLabel($attribute); $date_validator = new OEDateValidator(); if ($date_validator->validateAttribute($this, $attribute)) { if ($this->{$attribute} < $min_date) { $this->addError($attribute, strtr($params['message'], $params)); } } }