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
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 list below contains some available common identifiers. There are around 200 more included (see the python-stdnum docs for the complete list.)
identifier | spec | description |
---|---|---|
DOI | ISO 26324 | Digital Object Identifier |
GRid | Global Release Identifier | |
ISAN | ISO 15706 | International Standard Audiovisual Number |
ISBN | ISO 2108 | International Standard Book Number |
ISIL | ISO 15511 | International Standard Identifier for Libraries |
ISMN | ISO 10957 | International Standard Music Number for notated music |
ISSN | ISO 3297 | International Standard Serial Number |
identifier | spec | description |
---|---|---|
IMEI | International Mobile Equipment Identity | |
IMSI | ITU E.212 | International Mobile Subscriber Identity |
MAC address | IEEE 802 | Media Access Control address |
MEID | 3GPP2 S.R0048 | Mobile Equipment Identifier |
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 |
GS1-128 | GS-1 (product information) using Code 128 barcodes | |
IBAN | ISO 13616 | International Bank Account Number |
IMO number | International Maritime Organization number | |
ISIN | ISO 6166 | International Securities Identification Number |
LEI | ISO 17442 | Legal Entity Identifier |
ISO 11649 | Structured Creditor Reference |