updated-packages
This commit is contained in:
26
vendor/zendframework/zend-validator/src/Date.php
vendored
26
vendor/zendframework/zend-validator/src/Date.php
vendored
@@ -3,7 +3,7 @@
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2019 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
@@ -56,6 +56,11 @@ class Date extends AbstractValidator
|
||||
*/
|
||||
protected $format = self::FORMAT_DEFAULT;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $strict = false;
|
||||
|
||||
/**
|
||||
* Sets validator options
|
||||
*
|
||||
@@ -100,6 +105,17 @@ class Date extends AbstractValidator
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStrict(bool $strict) : self
|
||||
{
|
||||
$this->strict = $strict;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isStrict() : bool
|
||||
{
|
||||
return $this->strict;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if $value is a DateTime instance or can be converted into one.
|
||||
*
|
||||
@@ -110,11 +126,17 @@ class Date extends AbstractValidator
|
||||
{
|
||||
$this->setValue($value);
|
||||
|
||||
if (! $this->convertToDateTime($value)) {
|
||||
$date = $this->convertToDateTime($value);
|
||||
if (! $date) {
|
||||
$this->error(self::INVALID_DATE);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->isStrict() && $date->format($this->getFormat()) !== $value) {
|
||||
$this->error(self::FALSEFORMAT);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user