Improve Pydantic error handling

This commit is contained in:
Sina Atalay
2025-12-22 22:25:02 +03:00
parent 7ecb73a3b5
commit 12f7aaf8ce
3 changed files with 3 additions and 7 deletions

View File

@@ -3,14 +3,12 @@ Input should be 'present': This is not a valid `end_date`. Please use either YYY
Input should be a valid integer, unable to parse string as an integer: This is not a valid date. Please use either YYYY-MM-DD, YYYY-MM, or YYYY format.
String should match pattern '\\d{4}-\\d{2}(-\\d{2})?': This is not a valid date. Please use either YYYY-MM-DD, YYYY-MM, or YYYY format.
String should match pattern '\\b10\\..*': A DOI prefix should always start with "10.". For example, "10.1109/TASC.2023.3340648".
URL scheme should be 'http' or 'https': This is not a valid URL.
Input should be a valid URL: This is not a valid URL.
Field required: This field is required.
value is not a valid phone number: This is not a valid phone number.
month must be in 1..12: The month must be between 1 and 12.
day is out of range for month: The day is out of range for the month.
must be in range: The day is out of range for the month.
Extra inputs are not permitted: This field is unknown for this object. Please remove it.
Input should be a valid string: This field should be provided or removed to use the default value.
Input should be a valid list: This field should contain a list of items but it doesn't.
"value is not a valid color: value must be tuple, list or string": 'This is not a valid color. Here are some examples of valid colors: "red", "#ff0000", "rgb(255, 0, 0)", "hsl(0, 100%, 50%)"'
"value is not a valid color: string not recognised as a valid color": 'This is not a valid color. Here are some examples of valid colors: "red", "#ff0000", "rgb(255, 0, 0)", "hsl(0, 100%, 50%)"'
"value is not a valid color": 'This is not a valid color. Here are some examples of valid colors: "red", "#ff0000", "rgb(255, 0, 0)", "hsl(0, 100%, 50%)"'

View File

@@ -14,9 +14,6 @@ class Settings(BaseModelWithoutExtraKeys):
'The date to use as "current date" for filenames, the "last updated" label,'
" and time span calculations. Defaults to the actual current date."
),
json_schema_extra={
"default": None,
},
)
render_command: RenderCommand = pydantic.Field(
default_factory=RenderCommand,

View File

@@ -20,6 +20,7 @@ unwanted_locations = (
"list",
"literal",
"int",
"str",
"constrained-str",
"function-after",
)