How to Check a String Against a Pattern in pydantic with Field(pattern=...)
Some text has a fixed shape: a product code such as BIK-1001, a postcode, a 64-character checksum. pydantic checks that shape for you when the field is declared with Field(pattern=...) and a regular expression. This guide does it with pydantic 2.14.4 on Python 3.15.2.
