Implement date_format validation rule.
This commit is contained in:
parent
49331d74e2
commit
a40aabbb05
|
@ -36,6 +36,7 @@
|
||||||
"countbetween" => "The :attribute must have between :min and :max selected elements.",
|
"countbetween" => "The :attribute must have between :min and :max selected elements.",
|
||||||
"countmax" => "The :attribute must have less than :max selected elements.",
|
"countmax" => "The :attribute must have less than :max selected elements.",
|
||||||
"countmin" => "The :attribute must have at least :min selected elements.",
|
"countmin" => "The :attribute must have at least :min selected elements.",
|
||||||
|
"date_format" => "The :attribute must have a valid date format.",
|
||||||
"different" => "The :attribute and :other must be different.",
|
"different" => "The :attribute and :other must be different.",
|
||||||
"email" => "The :attribute format is invalid.",
|
"email" => "The :attribute format is invalid.",
|
||||||
"exists" => "The selected :attribute is invalid.",
|
"exists" => "The selected :attribute is invalid.",
|
||||||
|
|
|
@ -758,6 +758,19 @@ protected function validate_after($attribute, $value, $parameters)
|
||||||
return (strtotime($value) > strtotime($parameters[0]));
|
return (strtotime($value) > strtotime($parameters[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate the date conforms to a given format.
|
||||||
|
*
|
||||||
|
* @param string $attribute
|
||||||
|
* @param mixed $value
|
||||||
|
* @param array $parameters
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function validate_date_format($attribute, $value, $parameters)
|
||||||
|
{
|
||||||
|
return date_create_from_format($parameters[0], $value) !== false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the proper error message for an attribute and rule.
|
* Get the proper error message for an attribute and rule.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue