In this tutorial we will discuss how to work laravel decimal validation. How to validate number of digits after decimal space.
Laravel decimal validation rule
Laravel decimal validation rule must contain numeric value and only contain specified number of digits after decimal.
App/Http/Controllers/ProductController.php<?php namespace App\Http\Controllers; use Illuminate\Http\Request; class ProductController extends Controller { public function store(Request $request) { $request->validate([ 'price' => 'decimal:2' // must have two decimal spaces 'price1' => 'decimal:2,5' // must have 2-5 decimal spaces ]); } }
Read Also : Laravel array validation rule