· 6 years ago · Feb 04, 2019, 08:56 AM
1<?php
2
3namespace App\Rules;
4
5use Illuminate\Contracts\Validation\Rule;
6
7class RegisterEmailRule implements Rule
8{
9 private $domains = [
10 /* Default domains included */
11 "aol.com", "att.net", "comcast.net", "facebook.com", "gmail.com", "gmx.com", "googlemail.com",
12 "google.com", "hotmail.com", "hotmail.co.uk", "mac.com", "me.com", "mail.com", "msn.com",
13 "live.com", "sbcglobal.net", "verizon.net", "yahoo.com", "yahoo.co.uk",
14
15 /* Other global domains */
16 "email.com", "fastmail.fm", "games.com" /* AOL */, "gmx.net", "hush.com", "hushmail.com", "icloud.com",
17 "iname.com", "inbox.com", "lavabit.com", "love.com" /* AOL */, "outlook.com", "pobox.com", "protonmail.com",
18 "rocketmail.com" /* Yahoo */, "safe-mail.net", "wow.com" /* AOL */, "ygm.com" /* AOL */,
19 "ymail.com" /* Yahoo */, "zoho.com", "yandex.com",
20
21 /* United States ISP domains */
22 "bellsouth.net", "charter.net", "cox.net", "earthlink.net", "juno.com",
23
24 /* British ISP domains */
25 "btinternet.com", "virginmedia.com", "blueyonder.co.uk", "freeserve.co.uk", "live.co.uk",
26 "ntlworld.com", "o2.co.uk", "orange.net", "sky.com", "talktalk.co.uk", "tiscali.co.uk",
27 "virgin.net", "wanadoo.co.uk", "bt.com",
28
29 /* Domains used in Asia */
30 "sina.com", "qq.com", "naver.com", "hanmail.net", "daum.net", "nate.com", "yahoo.co.jp", "yahoo.co.kr", "yahoo.co.id", "yahoo.co.in", "yahoo.com.sg", "yahoo.com.ph",
31
32 /* French ISP domains */
33 "hotmail.fr", "live.fr", "laposte.net", "yahoo.fr", "wanadoo.fr", "orange.fr", "gmx.fr", "sfr.fr", "neuf.fr", "free.fr",
34
35 /* German ISP domains */
36 "gmx.de", "hotmail.de", "live.de", "online.de", "t-online.de" /* T-Mobile */, "web.de", "yahoo.de",
37
38 /* Italian ISP domains */
39 "libero.it", "virgilio.it", "hotmail.it", "aol.it", "tiscali.it", "alice.it", "live.it", "yahoo.it", "email.it", "tin.it", "poste.it", "teletu.it",
40
41 /* Russian ISP domains */
42 "mail.ru", "rambler.ru", "yandex.ru", "ya.ru", "list.ru",
43
44 /* Belgian ISP domains */
45 "hotmail.be", "live.be", "skynet.be", "voo.be", "tvcablenet.be", "telenet.be",
46
47 /* Argentinian ISP domains */
48 "hotmail.com.ar", "live.com.ar", "yahoo.com.ar", "fibertel.com.ar", "speedy.com.ar", "arnet.com.ar",
49
50 /* Domains used in Mexico */
51 "yahoo.com.mx", "live.com.mx", "hotmail.es", "hotmail.com.mx", "prodigy.net.mx",
52
53 /* Domains used in Brazil */
54 "yahoo.com.br", "hotmail.com.br", "outlook.com.br", "uol.com.br", "bol.com.br", "terra.com.br", "ig.com.br", "itelefonica.com.br", "r7.com", "zipmail.com.br", "globo.com", "globomail.com", "oi.com.br"
55 ];
56 /**
57 * Create a new rule instance.
58 *
59 * @return void
60 */
61 public function __construct()
62 {
63 //
64 }
65
66 /**
67 * Determine if the validation rule passes.
68 *
69 * @param string $attribute
70 * @param mixed $value
71 * @return bool
72 */
73 public function passes($attribute, $value)
74 {
75 list($user, $domain) = explode('@', $value);
76 if(!in_array($domain, $this->domains)){
77 return true;
78 }
79 return false;
80 }
81
82 /**
83 * Get the validation error message.
84 *
85 * @return string
86 */
87 public function message()
88 {
89 return 'O e-mail precisa ser corporativo';
90 }
91}