Recently whilst building a Laravel 4 application, I needed to validate some monetary values in the form of: 10.00, 5.00 and so on. Surprisingly Laravel’s default validation options don’t account for monetary values, so you have to use a regular expression instead.
Using the numeric validation type also works as I believe it uses PHP’s in-built function is_numeric() to validate numbers. I prefer regular expressions because you have greater control over what is allowed and isn’t.
Add the following regex code to your rules array for the field you are validating. This will validate numbers that end in two digits with no limit on the digits that precede the ending digits.
$rules = array(
'pricing_value' => 'regex:/^\d*(\.\d{2})?$/'
);
Thanks, its works for me ๐ Greetings!
dqe
Great Thanks Man