summaryrefslogtreecommitdiff
path: root/src/Validators/DateFormatValidator.php
diff options
context:
space:
mode:
authorAsko Nõmm <asko@repl.ee>2023-09-25 01:35:47 +0300
committerAsko Nõmm <asko@repl.ee>2023-09-25 01:35:47 +0300
commitef1dd318d437bb33adddf226c546e85f4744ce8c (patch)
tree8910bd4cc0b2ce2827aecfa19ecf2453058af575 /src/Validators/DateFormatValidator.php
parentd2a1290423e1102b23fc8e042cef5420a42c02af (diff)
Update stuff
Diffstat (limited to 'src/Validators/DateFormatValidator.php')
-rw-r--r--src/Validators/DateFormatValidator.php14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Validators/DateFormatValidator.php b/src/Validators/DateFormatValidator.php
index fedbb7d..50312ea 100644
--- a/src/Validators/DateFormatValidator.php
+++ b/src/Validators/DateFormatValidator.php
@@ -1,13 +1,15 @@
<?php
-namespace Askonomm\Hird\Validators;
+declare(strict_types=1);
+
+namespace Asko\Hird\Validators;
/**
* Implements a DateFormat validator that has a job
* of validating that a given date is in the correct
* format.
*
- * @author Asko Nomm <asko@bien.ee>
+ * @author Asko Nomm <asko@asko.dev>
*/
class DateFormatValidator implements Validator
{
@@ -20,12 +22,12 @@ class DateFormatValidator implements Validator
* @param mixed $modifier
* @return boolean
*/
- public static function validate(string $field, mixed $value, mixed $modifier = null): bool
+ public function validate(string $field, mixed $value, mixed $modifier = null): bool
{
if ($value) {
$datetime = \DateTime::createFromFormat($modifier, $value);
- return $datetime !== false && !array_sum($datetime::getLastErrors());
+ return $datetime !== false;
}
return true;
@@ -38,8 +40,8 @@ class DateFormatValidator implements Validator
* @param mixed $modifier
* @return string
*/
- public static function composeError(string $field, mixed $modifier = null): string
+ public function composeError(string $field, mixed $modifier = null): string
{
- return "${field} does not match the required date format ${modifier}.";
+ return "{$field} does not match the required date format {$modifier}.";
}
}