Validation library choice#

Quart-Schema is agnostic to your choice of validation library with msgspec and Pydantic both supported. This choice must be made at installation, with either the msgspec or pydantic extra used.


If you install both msgspec and Pydantic you can control which is used for builtin types by setting the QUART_SCHEMA_CONVERSION_PREFERENCE to either msgspec or pydantic.

This documentation will show examples for both msgspec and Pydantic.


If you choose msgspec you can contruct the validation classes as dataclasses, attrs definitions, or msgspec structs.

from attrs import define

class Person:
    name: str


If you choose Pydantic you can contruct the validation classes as dataclasses, Pydantic dataclasses, or BaseModels.

from dataclasses import dataclass

class Person:
    name: str


Note that lists are valid validation models i.e. the following is valid for any of the above Person defintions,

from typing import List

async def index():