Merge pull request #153 from zouravand/master
add multiple jalali date format validator
This commit is contained in:
2 files changed
+21
No files matched your search
@@ -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
|
||||||
|
|||||||
@@ -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',
|
||||||
|
|||||||
Reference in new issue
Block a user