Laravel checks decimal value 0-99.99

Laravel has no validation for decimal , so I need a regex or some other validation method to validate the numeric value 0 - 99.99

I tried

 required|regex:^\d{0,2}(\.\d{1,2})?$/ required|regex:[1-9]\d?(\.\d\d?)?|0\.[1-9]\d?||0\.0[1-9] required|regex:/[1-9]\d?(\.\d\d?)?|0\.[1-9]\d?||0\.0[1-9]/ required|regex:/[\d]{2}.[\d]{2}/ required|regex:/[\d]{0-2}.[\d]{0,2}/ 

I either get an "invalid format" when I try to enter 0.05 , or unknown modifiers for preg_match

any help with regex needed to check the decimal in laravel is evaluated (with optional values ​​before or after the decimal

+7
regex validation laravel-5 decimalformat
source share
3 answers

The Laravel between validation rule is actually quite powerful and can also handle decimal values. Therefore, there is no need to use a regular expression:

 'required|between:0,99.99' 
+20
source share

laravel (5?) between the rule always gets that it should parse the decimal number, you need to add a numerical value for the correct check

 'required|numeric|between:0,99.99', 
+24
source share

this will work for a number that allows two decimal precision:

 function rules(){ return [ 'field_name'=> array('regex:/^(?:d*.d{1,2}|d+)$/','min:1','max:10') ]; } 
+3
source share

All Articles