Skip to main content

Pydantic Identifiers

Project description

Pydentic

Pydentic is a thin wrapper over python-stdnum to facilitate the use of its extensive collection of validators and formatters in Pydantic models.

pip install pydentic

Features

Automatic validation and formatting.

from pydentic.strings import Iban
from pydantic import BaseModel

class User(BaseModel):
    name: str
    iban: Iban

user = User(name='John Doe', iban='es1000750080110600658108')
print(user)

#> name='John Doe' iban='ES10 0075 0080 1106 0065 8108'
# note the extra last character
user = User(name='John Doe', iban='es1000750080110600658108Ñ')

# raises
...
pydantic.error_wrappers.ValidationError: 1 validation error for User
iban
  es1000750080110600658108Ñ (type=value_error.format; error=invalid literal for int() with base 36: 'Ñ')

Title and description in the JSON Schema.

{
  "title": "User",
  "type": "object",
  "properties": {
    "name": {
      "title": "Name",
      "type": "string"
    },
    "iban": {
      "title": "IBAN",
      "description": "International Bank Account Number",
      "type": "string"
    }
  },
  "required": ["user", "iban"]
}

The classes Isan, Isbn, and Issn include a urn property that, not surprisingly, returns their URN.

from pydentic.strings import Isbn
from pydantic import BaseModel

class Book(BaseModel):
    author: str
    title: str
    isbn: Isbn

book = Book(author='D. Hofstadter', title='GEB', isbn='978-0-465-02656-2')
print(book.isbn.urn)

#> urn:isbn:9780465026562

Identifiers

The list below contains some available international identifiers. There are around 200 more identifiers included (see the python-stdnum docs for the complete list.)

identifier spec description
BIC ISO 9362 Business Identifier Code
BIC-Code ISO 6346 International standard for container identification
Bitcoin address
CAS RN Chemical Abstracts Service Registry Number
CUSIP number financial security identification number
EAN International Article Number
FIGI OMG FIGI Financial Instrument Global Identifier
GRid Global Release Identifier
GS1-128 GS-1 (product information) using Code 128 barcodes
IBAN ISO 13616 International Bank Account Number
IMEI International Mobile Equipment Identity
IMO number International Maritime Organization number
IMSI International Mobile Subscriber Identity
ISAN ISO 15706 International Standard Audiovisual Number
ISBN ISO 2108 International Standard Book Number
ISIL ISO 15511 International Standard Identifier for Libraries
ISIN ISO 6166 International Securities Identification Number
ISMN ISO 10957 International Standard Music Number for notated music
ISSN ISO 3297 International Standard Serial Number
LEI ISO 17442 Legal Entity Identifier
MAC address Media Access Control address
MEID Mobile Equipment Identifier
ISO 11649 Structured Creditor Reference

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

pydentic-0.0.1.dev3.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

pydentic-0.0.1.dev3-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file pydentic-0.0.1.dev3.tar.gz.

File metadata

  • Download URL: pydentic-0.0.1.dev3.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1

File hashes

Hashes for pydentic-0.0.1.dev3.tar.gz
Algorithm Hash digest
SHA256 4c5ee9c260e3cbcdb2a2d725b1d98046cb2b5298e6d6154449a685cf4cca85ec
MD5 99661add11750b6c59ffbf211ac3089c
BLAKE2b-256 f82ef14d8bc4141b680db8e8b175c167c38ff02c67569ac276f461a02f300cdd

See more details on using hashes here.

File details

Details for the file pydentic-0.0.1.dev3-py3-none-any.whl.

File metadata

  • Download URL: pydentic-0.0.1.dev3-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1

File hashes

Hashes for pydentic-0.0.1.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 b37f690f262e02e781deae8588a411c596489bc2837701fbb5e8c59b31b4236e
MD5 770f617c1fec1dc0c637b190da890d9a
BLAKE2b-256 87cc91315af0dd1248fff43ce8e94bb19a7b480962115a632d59bc3f9f85f92c

See more details on using hashes here.

Supported by

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