How to use Laravel Rules for Validation of Numbers?

Laravel rules help in the validation of numbers, integers, and digits. These rules use Laravel built-in functions that ease all types of validations.

public function validate_data(Request $request)
     $num_validate = $request->validate([
     phone_number=> 'required|numeric|min:10'

We have shown the example above, where the validate_data function defines the rule to validate a phone number in Laravel. This will validate any phone number before saving it to the database.

Laravel rules can be easily defined by passing the specifications for the number we use. For example, for a phone number, we check if the number contains numerals and is of a specific length.

We can define other rules also, for example for measurements to have a minimum or maximum value we can write the rule as shown below.

$rules = ['Fno' => 'numeric|min:2|max:5', 'Lno' => 'numeric|min:2'];