Last active
May 25, 2021 06:41
-
-
Save allanphilipbarku/b76b49d99c3789926ee30ae34905a017 to your computer and use it in GitHub Desktop.
Laravel Year Validation
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 | |
$this->validate( | |
$request,[ | |
'year' => 'integer|required|digits:4|min:1900|max:' . (date('Y') - 1), | |
] | |
); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The year concatenated is minus 1 to limit it to the previous year. Carbon can be used to be more accurate with the cut off date