1

I want to check the input is an email inside the validation class.I use custom validation for that because of the email comes as a list separated by commas.I want to get email one by one and validate them. Can I check whether email is valid without using regex?

Thank you.

1 Answer 1

2

Try:

$emailsInput = Input::get('email');
$emails = explode(',', $emails);
foreach($emails as $email) {
    $validator = Validator::make(
        ['email' => $email],
        ['email' => 'required|email']
    );
    if ($validator->fails())
    {
     // There is an invalid email in the input.
    }
}

Assuming that the input's format is like: [email protected],[email protected],[email protected]

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.