in Laravel application I need save year input data, it is should be numeric number and should include only 4 numbers. this is current system,
'year' => 'required|min:4|numeric',
this is working but can enter more than 4 numbers. how can enter only 4 numbers here?
You can try
'year' => 'required|digits:4|integer|min:1900|max:'.(date('Y')+1),
the +1 is to account for a new year registration in Australia for example. You don't want to accidentally cut them off because they are ahead. Or, maybe more precise, use \Carbon\Carbon::tomorrow()->year
For numeric data, value corresponds to a given integer value:
'year' => 'required|integer|min:1900|max:2018'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With