File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ class Emails (list ):
2+ def __init__ (self , emails ):
3+ # Tekrarlayan elemanları temizlemek için set kullanıyoruz
4+ # test_validate_duplicates testi bunu gerektiriyor.
5+ super ().__init__ (set (emails ))
6+ self .validate ()
7+
8+ def validate (self ):
9+ for email in self :
10+ # Sadece string veri tipine izin ver
11+ if not isinstance (email , str ):
12+ raise ValueError ("Only strings are allowed" )
13+
14+ # Basit e-posta format kontrolü: '@' ve sonrasında '.' olmalı
15+ if "@" not in email :
16+ raise ValueError ("Invalid email: missing @" )
17+
18+ domain = email .split ("@" )[- 1 ]
19+ if "." not in domain :
20+ raise ValueError ("Invalid email: missing dot in domain" )
21+
22+ def __repr__ (self ):
23+ # Sınıfın string temsili: Emails(['a@b.com', ...]) formatında
24+ return f"Emails({ super ().__repr__ ()} )"
25+
26+ def __str__ (self ):
27+ return self .__repr__ ()
You can’t perform that action at this time.
0 commit comments