-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
Date, | ||
DateTime, | ||
Decimal, | ||
Email, | ||
Float, | ||
Integer, | ||
Number, | ||
|
@@ -835,6 +836,16 @@ def test_validation_error_is_hashable(): | |
hash(error) | ||
|
||
|
||
def test_email(): | ||
validator = Email() | ||
value, error = validator.validate_or_error("[email protected]") | ||
assert value == "[email protected]" | ||
|
||
validator = Email() | ||
value, error = validator.validate_or_error("example.com") | ||
assert error == ValidationError(text="Must be a valid email format.", code="format") | ||
|
||
|
||
def test_password(): | ||
validator = Password() | ||
value, _ = validator.validate_or_error("secret") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -500,3 +500,11 @@ def test_definitions_to_json_schema(): | |
}, | ||
} | ||
} | ||
|
||
|
||
def test_schema_email_serialization(): | ||
user = typesystem.Schema(fields={"email": typesystem.Email()}) | ||
|
||
item = {"email": "[email protected]"} | ||
data = user.serialize(item) | ||
assert data == {"email": "[email protected]"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters