Created
February 6, 2017 04:54
-
-
Save itsrachelfish/6c4b71345e7598154a635b84b927c024 to your computer and use it in GitHub Desktop.
Laravel custom validation messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
... | |
Validator::extend('time', function($attribute, $value, $parameters) | |
{ | |
$value = trim($value); | |
// Check against 12 hour time (with AM/PM) or 24 hour time | |
$twelve = date_parse_from_format('h:i a', $value); | |
$twentyfour = date_parse_from_format('H:i', $value); | |
if($twelve['error_count'] === 0 || $twentyfour['error_count'] === 0) | |
{ | |
return true; | |
} | |
return false; | |
}); | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
... | |
'custom' => | |
[ | |
'password' => | |
[ | |
'hashed' => "Invalid password entered" | |
], | |
'validation' => | |
[ | |
'time' => "DEPR DERP", | |
], | |
'custom_end_time.time' => "why in the world", | |
'validation.time' => 'HELLOO???', | |
'time' => "uhhh", | |
'*.time' => 'what????' | |
], | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment