Now let’s see example of how to validate an eamil address in laravel and php. We will show email validation in laravel. we will learn how to validate an email with regex in laravel. if you want to check .(dot) from the email address exist or not. The problem is when I remove . (dot) from the email address, it accepts it as a invalid email address.

This article will give you how to validate .(dot) from email address in laravel and php. I will give three solution for .(dot) validation of email address in php laravel. one solution in laravel and two solution in php. So let’s see the bellow solution.

Solution : In Laravel

/**
 * Get the validation rules that apply to the request.
 *
 * @return array
 */
public function store(Request $request)
{
    $request->validate([
        'email' => 'regex:/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix'
    ]);
}

Solution 1 : In PHP

The function preg_match() checks the input matching with patterns using regular expressions.

<?php
    function validEmail($str) {
        return (!preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
    }
    if(!validEmail("abc@abccom")){
        echo "Invalid email address.";
    }
    else{
        echo "Valid email address.";
    }
?>

Output

Invalid email address.

#laravel #php #web-development #programming #developer

How to Validate an Email Address in Laravel
173.95 GEEK