返回排行榜

pydantic/pydantic

Pythonpydantic.dev/docs/validation

Data validation using Python type hints

validationparsingjson-schemapydanticpython39pythonhintspython310python311python312python313
Star 增长趋势
Star
28.3k
Forks
2.8k
周增长
Issues
531
10k20k
2017年5月2020年5月2023年6月2026年7月
制品库PyPIpip install pydantic
README

Pydantic Validation

CI Coverage pypi CondaForge downloads versions license Pydantic v2 llms.txt

Data validation using Python type hints.

Fast and extensible, Pydantic plays nicely with your linters/IDE/brain. Define how data should be in pure, canonical Python 3.10+; validate it with Pydantic.

Pydantic Logfire :fire:

We've launched Pydantic Logfire to help you monitor your applications. Learn more

Pydantic V1.10 vs. V2

Pydantic V2 is a ground-up rewrite that offers many new features, performance improvements, and some breaking changes compared to Pydantic V1.

If you're using Pydantic V1 you may want to look at the pydantic V1.10 Documentation or, 1.10.X-fixes git branch. Pydantic V2 also ships with the latest version of Pydantic V1 built in so that you can incrementally upgrade your code base and projects: from pydantic import v1 as pydantic_v1.

Help

See documentation for more details.

Installation

Install using pip install -U pydantic or conda install pydantic -c conda-forge. For more installation options to make Pydantic even faster, see the Install section in the documentation.

A Simple Example

from datetime import datetime
from typing import Optional
from pydantic import BaseModel

class User(BaseModel):
    id: int
    name: str = 'John Doe'
    signup_ts: Optional[datetime] = None
    friends: list[int] = []

external_data = {'id': '123', 'signup_ts': '2017-06-01 12:22', 'friends': [1, '2', b'3']}
user = User(**external_data)
print(user)
#> User id=123 name='John Doe' signup_ts=datetime.datetime(2017, 6, 1, 12, 22) friends=[1, 2, 3]
print(user.id)
#> 123

Contributing

For guidance on setting up a development environment and how to make a contribution to Pydantic, see Contributing to Pydantic.

Reporting a Security Vulnerability

See our security policy.

相关仓库
react-hook-form/react-hook-form

📋 React Hooks for form state management and validation (Web + React Native)

TypeScriptnpmMIT Licensetypescriptreact-hooks
react-hook-form.com
44.8k2.5k
validatorjs/validator.js

String validation

JavaScriptnpmMIT Licensevalidationsanitization
23.7k2.5k
hapijs/joi

The most powerful data validation library for JS

JavaScriptnpmOtherjavascriptschema
21.2k1.5k
go-playground/validator

:100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving

GoGo ModulesMIT Licensevalidationtranslation
20.1k1.4k
567-labs/instructor

structured outputs for llms

PythonPyPIMIT Licenseopenaipython
python.useinstructor.com
13.6k1.2k
redux-form/redux-form

A Higher Order Component using react-redux to keep form state in a Redux store

JavaScriptnpmMIT Licensereduxredux-form
redux-form.com
12.5k1.6k
typestack/class-validator

Decorator-based property validation for classes.

TypeScriptnpmMIT Licensevalidationvalidator
11.8k846
apple/pkl

A configuration as code language with rich validation and tooling.

JavaMavenApache License 2.0pkljava
pkl-lang.org
11.5k393
logaretm/vee-validate

✅ Painless Vue forms

TypeScriptnpmMIT Licensevuevalidation
vee-validate.logaretm.com/v4
11.3k1.3k
instructor-ai/instructor

structured outputs for llms

PythonPyPIMIT Licenseopenaipython
python.useinstructor.com
9.7k749
open-circle/valibot

The modular and type safe schema library for validating structural data 🤖

TypeScriptnpmMIT Licensebundle-sizemodular
valibot.dev
8.8k365
cakephp/cakephp

CakePHP: The Rapid Development Framework for PHP - Official Repository

PHPPackagistMIT Licensecakephpphp
cakephp.org
8.8k3.4k