File tree 2 files changed +25
-0
lines changed
Lecture 07 - RegEx/Assignments/05_Response_Validation
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ # https://pypi.org/project/validator-collection/
2
+ # https://pypi.org/project/validators/
3
+
4
+ from validator_collection import checkers
5
+ import validators
6
+
7
+ def main ():
8
+ print ("Valid" if validate (input ("What's your email address? " )) else "Invalid" )
9
+
10
+
11
+ def validate (email ):
12
+ return checkers .is_email (email ) and validators .email (email )
Original file line number Diff line number Diff line change
1
+ from response import validate
2
+
3
+
4
+ def test_valid_emails ():
5
+ assert validate ("malan@harvard.edu" ) == True
6
+ assert validate ("s123456@studenti.polito.it" ) == True
7
+ assert validate ("name.surname@polito.it" ) == True
8
+ assert validate ("name_surname@polito.it" ) == True
9
+
10
+
11
+ def test_invalid_emails ():
12
+ assert validate ("malan@@@harvard.edu" ) == False
13
+ assert validate ("malan@harvard..edu" ) == False
You can’t perform that action at this time.
0 commit comments