Merge pull request #153 from zouravand/master

add multiple jalali date format validator
This commit is contained in:
Nasser Hekmati authored and GitHub committed 2023-05-14 21:38:04 +03:30
commit 1ece72e1f9
2 files changed
+21

No files matched your search

+17
View File
@@ -30,6 +30,23 @@ class JalaliValidator
return true; return true;
} }
/**
* Determines if an input is a valid Jalali date with the specified format
* @param string $attribute
* @param string $value
* @param array $parameters
* @return bool
*/
public function validateDateMultiFormat(string $attribute, string $value, array $parameters): bool
{
foreach ($parameters as $format) {
if ($this->validateDate($attribute, $value, $format)) {
return true;
}
}
return false;
}
/** /**
* Determines if an input is a valid Jalali date with the specified format and * Determines if an input is a valid Jalali date with the specified format and
* it is equal a given date * it is equal a given date
+4
View File
@@ -14,6 +14,10 @@ class VertaServiceProvider extends ServiceProvider
'extend' => 'validateDate', 'extend' => 'validateDate',
'replacer' => 'replaceDateOrDatetime', 'replacer' => 'replaceDateOrDatetime',
], ],
'jdate_multi_format' => [
'extend' => 'validateDateMultiFormat',
'replacer' => 'replaceDateOrDatetime',
],
'jdate_equal' => [ 'jdate_equal' => [
'extend' => 'validateDateEqual', 'extend' => 'validateDateEqual',
'replacer' => 'replaceDateAfterOrBeforeOrEqual', 'replacer' => 'replaceDateAfterOrBeforeOrEqual',