Skip to main content

Type handling and normalization for non-standard types like email, phone numbers, money, dates, etc. serializable and deserializable as JSON, JSON Schema, and Pydantic.

Project description

atypical

Custom types for things like phone numbers, emails, etc. with normalization, Pydantic handling and JSON Schema serialization

Examples

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/"
}
'''

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

atypical-0.5.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

atypical-0.5.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file atypical-0.5.0.tar.gz.

File metadata

  • Download URL: atypical-0.5.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for atypical-0.5.0.tar.gz
Algorithm Hash digest
SHA256 ce2ed6f1eb843cad17322f26ef867c55489f389b282118550ef4bde80599bbee
MD5 8b8e4da5405f438b91d4495b610a68bd
BLAKE2b-256 c5d1c1d1212a96912759e6366c4645a153fb8a722328dafebc397f4c87dfb984

See more details on using hashes here.

Provenance

The following attestation bundles were made for atypical-0.5.0.tar.gz:

Publisher: build.yml on goodcleanfun/atypical

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file atypical-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: atypical-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for atypical-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4856c3a2f2919bb40c680195fa0c9517d6cacd4c2552d0df96707f02a57a132
MD5 6ca6e8b40531afc457e225d21698f8cd
BLAKE2b-256 a96e07fd38514dfd4d9e7031d7c8459db115ec921b993ee86279d1e44865476e

See more details on using hashes here.

Provenance

The following attestation bundles were made for atypical-0.5.0-py3-none-any.whl:

Publisher: build.yml on goodcleanfun/atypical

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page