# contact-forms/1.9.2/classes/Validation/Date.php

Contact Forms by Cimatti, version 1.9.2. 29 lines.

- Page: https://pluginprobe.com/plugins/contact-forms/1.9.2/code/classes/Validation/Date.php
- Raw: https://pluginprobe.com/plugins/contact-forms/1.9.2/raw/classes/Validation/Date.php
- Modified: 2023-06-12T07:53:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/contact-forms/1.9.2/code/classes/Validation/Date.php#L10-L20`.

```php
<?php
class AccuaForm_Validation_Date extends Validation {
  protected $message = "Error: %element% must contain a valid date.";
  protected $minDate = null;
  protected $maxDate = null;

  public function isValid($value) {
    if ($value === '') {
      return true;
    }
    if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) {
      try {
        $date = new DateTime($value);
        if ($date) {
          if ($this->minDate && ($value < $this->minDate)) {
            return false;
          }
          if ($this->maxDate && ($value > $this->maxDate)) {
            return false;
          }
          return true;
        }
      } catch (Exception $e) {
      }
    }
    return false;
  }
}

```
