-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add email column * fix VSCode format error * dependencies changed * add min version to pydantic * add link to piccolo admin docs * add an extra test to make sure email validation works * update `Email` docstring - add more links Co-authored-by: Daniel Townsend <[email protected]>
- Loading branch information
1 parent
5c2b35b
commit 0f785ab
Showing
7 changed files
with
45 additions
and
3 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
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
Date, | ||
Decimal, | ||
DoublePrecision, | ||
Email, | ||
Float, | ||
ForeignKey, | ||
Integer, | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ Jinja2>=2.11.0 | |
targ>=0.3.7 | ||
inflection>=0.5.1 | ||
typing-extensions>=3.10.0.0 | ||
pydantic>=1.6 | ||
pydantic[email]>=1.6 |
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
JSON, | ||
JSONB, | ||
Array, | ||
Email, | ||
Integer, | ||
Numeric, | ||
Secret, | ||
|
@@ -32,6 +33,25 @@ class Director(Table): | |
pydantic_model(name="short name") | ||
|
||
|
||
class TestEmailColumn(TestCase): | ||
def test_email(self): | ||
class Director(Table): | ||
email = Email() | ||
|
||
pydantic_model = create_pydantic_model(table=Director) | ||
|
||
self.assertEqual( | ||
pydantic_model.schema()["properties"]["email"]["format"], | ||
"email", | ||
) | ||
|
||
with self.assertRaises(ValidationError): | ||
pydantic_model(email="not a valid email") | ||
|
||
# Shouldn't raise an exception: | ||
pydantic_model(email="[email protected]") | ||
|
||
|
||
class TestNumericColumn(TestCase): | ||
""" | ||
Numeric and Decimal are the same - so we'll just test Numeric. | ||
|