OEDateValidator::validateAttribute PHP Method

validateAttribute() public method

public validateAttribute ( $object, $attribute )
    public function validateAttribute($object, $attribute)
    {
        if (isset($object->{$attribute}) && !empty($object->{$attribute})) {
            if (!$this->validateValue($object->{$attribute})) {
                if (strtotime($object->{$attribute}) != false) {
                    $this->addError($object, $attribute, $object->getAttributeLabel($attribute) . ' is not in valid format: ' . $object->{$attribute});
                } else {
                    $this->addError($object, $attribute, $object->getAttributeLabel($attribute) . ' is not a valid date: ' . $object->{$attribute});
                }
                return false;
            }
            return true;
        }
    }

Usage Example

 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.');
         }
     }
 }
All Usage Examples Of OEDateValidator::validateAttribute