Reputation:
i'm validating an email input like this:
'email' => 'required|unique:users|email|max:255'
I want my email to be in a specific domain, example: [email protected]
so it needs to end with the correct domain
I cannot find a solution nowhere, I have tried regex but i don't understand it and it doesn't seem to work in this case
'regex:/(^([a-zA-Z]+)(\d+)?$)/u'
how can I validate it in this case? can you please help me?
Upvotes: 1
Views: 1410
Reputation: 2040
Try regex:/(.+)@gmail\.com/i
This means
/
start of regex
(.+)
any characters, but at least 1 character must be present (i.e. don't accept "@gmail.com" as an address)
@gmail\.com
the domain with the dot escaped, because the dot is a special character in regex
/
end of regex
i
i option to make it case insensitive, so people can put GMAIL.com or gMail.com etc
Upvotes: 4