Name | atypical JSON |
Version |
0.3.1
JSON |
| download |
home_page | None |
Summary | Type handling and normalization for non-standard types like email, phone numbers, money, dates, etc. serializable and deserializable as JSON, JSON Schema, and Pydantic. |
upload_time | 2024-04-14 05:50:13 |
maintainer | None |
docs_url | None |
author | Al Barrentine |
requires_python | >=3.8 |
license | None |
keywords |
atypical
utils
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# atypical
Custom types for things like phone numbers, emails, etc. with normalization, Pydantic handling and JSON Schema serialization
## Examples
```python
from atypical.email import Email
from atypical.money import Money
from atypical.phone import PhoneNumber
from atypical.url import NormalizedURL
from sartorial.schema import Schema
class MyModel(Schema):
email: Email
phone_number: PhoneNumber
amount: Money
website: NormalizedURL
import json
print(MyModel.model_json_schema()) # or MyModel.to_schema_dict()
# Output
'''
{
"additionalProperties": true,
"properties": {
"email": {
"format": "email",
"type": "string"
},
"phone_number": {
"format": "phone",
"type": "string"
},
"amount": {
"format": "money",
"type": "string"
},
"website": {
"format": "normalized-url",
"type": "string"
}
},
"required": [
"email",
"phone_number",
"amount",
"website"
],
"title": "MyModel",
"type": "object"
}
'''
m = MyModel(email="foo.bar+baz@gmail",
phone_number="1 (212) 555-6789",
amount="$100",
website="example.com")
print(m.model_dump_json(indent=4)) # or m.to_json()
# Output
'''
{
"email": "foobar@gmail.com",
"phone_number": "+12125556789",
"amount": "$100.00",
"website": "https://example.com/"
}
'''
```
Raw data
{
"_id": null,
"home_page": null,
"name": "atypical",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "atypical, utils",
"author": "Al Barrentine",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/58/a4/ee1a23880fc87c539534f2e21c87fd957ff85de58f2ea959cb82912b00e4/atypical-0.3.1.tar.gz",
"platform": null,
"description": "# atypical\nCustom types for things like phone numbers, emails, etc. with normalization, Pydantic handling and JSON Schema serialization\n\n## Examples\n\n```python\nfrom atypical.email import Email\nfrom atypical.money import Money\nfrom atypical.phone import PhoneNumber\nfrom atypical.url import NormalizedURL\nfrom sartorial.schema import Schema\n\n\nclass MyModel(Schema):\n email: Email\n phone_number: PhoneNumber\n amount: Money\n website: NormalizedURL\n\nimport json\nprint(MyModel.model_json_schema()) # or MyModel.to_schema_dict()\n\n# Output\n'''\n{\n \"additionalProperties\": true,\n \"properties\": {\n \"email\": {\n \"format\": \"email\",\n \"type\": \"string\"\n },\n \"phone_number\": {\n \"format\": \"phone\",\n \"type\": \"string\"\n },\n \"amount\": {\n \"format\": \"money\",\n \"type\": \"string\"\n },\n \"website\": {\n \"format\": \"normalized-url\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"email\",\n \"phone_number\",\n \"amount\",\n \"website\"\n ],\n \"title\": \"MyModel\",\n \"type\": \"object\"\n}\n '''\n\nm = MyModel(email=\"foo.bar+baz@gmail\",\n phone_number=\"1 (212) 555-6789\",\n amount=\"$100\",\n website=\"example.com\")\n\nprint(m.model_dump_json(indent=4)) # or m.to_json()\n\n# Output\n'''\n{\n \"email\": \"foobar@gmail.com\",\n \"phone_number\": \"+12125556789\",\n \"amount\": \"$100.00\",\n \"website\": \"https://example.com/\"\n}\n'''\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Type handling and normalization for non-standard types like email, phone numbers, money, dates, etc. serializable and deserializable as JSON, JSON Schema, and Pydantic.",
"version": "0.3.1",
"project_urls": {
"Homepage": "https://github.com/goodcleanfun/atypical",
"Repository": "https://github.com/goodcleanfun/atypical"
},
"split_keywords": [
"atypical",
" utils"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5ae08880983d331889bac86513a444b80daa6306efa50d94bc1bb215acfdf35b",
"md5": "629519d1d5234cf214dabed17922ca48",
"sha256": "a521c113ec46fae3bab68178943a44ec03103a6b268a2f55e2318487ec2dcb05"
},
"downloads": -1,
"filename": "atypical-0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "629519d1d5234cf214dabed17922ca48",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 11796,
"upload_time": "2024-04-14T05:50:11",
"upload_time_iso_8601": "2024-04-14T05:50:11.950910Z",
"url": "https://files.pythonhosted.org/packages/5a/e0/8880983d331889bac86513a444b80daa6306efa50d94bc1bb215acfdf35b/atypical-0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "58a4ee1a23880fc87c539534f2e21c87fd957ff85de58f2ea959cb82912b00e4",
"md5": "67d00562e889dd8d65884d88078454a4",
"sha256": "3b4c0e5997fb7389077b854317667e7db1a9582762865706f89911ff58995ea8"
},
"downloads": -1,
"filename": "atypical-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "67d00562e889dd8d65884d88078454a4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 11150,
"upload_time": "2024-04-14T05:50:13",
"upload_time_iso_8601": "2024-04-14T05:50:13.461263Z",
"url": "https://files.pythonhosted.org/packages/58/a4/ee1a23880fc87c539534f2e21c87fd957ff85de58f2ea959cb82912b00e4/atypical-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-14 05:50:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "goodcleanfun",
"github_project": "atypical",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "atypical"
}