File: validation_error.py

package info (click to toggle)
flask-openapi3 4.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,224 kB
  • sloc: python: 4,802; makefile: 14; javascript: 5
file content (24 lines) | stat: -rw-r--r-- 1,038 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -*- coding: utf-8 -*-
# @Author  : llc
# @Time    : 2021/5/10 14:51
from typing import Any

from pydantic import BaseModel, Field


class ValidationErrorModel(BaseModel):
    # More information: https://docs.pydantic.dev/latest/concepts/models/#error-handling
    type: str = Field(..., title="Error Type", description="A computer-readable identifier of the error type.")
    loc: list[Any] = Field(..., title="Location", description="The error's location as a list.")
    msg: str = Field(..., title="Message", description="A human readable explanation of the error.")
    input: Any = Field(..., title="Input", description="The input provided for validation.")
    url: str | None = Field(None, title="URL", description="The URL to further information about the error.")
    ctx: dict[str, Any] | None = Field(
        None,
        title="Error context",
        description="An optional object which contains values required to render the error message.",
    )


# backward compatibility
UnprocessableEntity = ValidationErrorModel