entry_with_date
¶
ArbitraryDate = Annotated[int | str, pydantic.AfterValidator(validate_arbitrary_date)]
¶
BaseEntryWithDate
¶
Bases: BaseEntry
date = pydantic.Field(default=None, description="The date of this event in YYYY-MM-DD, YYYY-MM, or YYYY format, or any custom text like 'Fall 2023'. Use this for single-day or imprecise dates. For date ranges, use `start_date` and `end_date` instead.", examples=['2020-09-24', '2020-09', '2020', 'Fall 2023', 'Summer 2020'])
class-attribute
instance-attribute
¶
entry_type_in_snake_case
cached
property
¶
Convert class name to snake_case for template attribute lookup.
Why
Template collections store entry templates keyed by snake_case
entry type names (e.g., education_entry). This property
enables dynamic lookup from the class name.
Returns:
-
str–Snake_case version of the entry class name.
model_config = pydantic.ConfigDict(json_schema_extra={'description': None})
class-attribute
instance-attribute
¶
validate_arbitrary_date(date)
¶
Validate date format while allowing flexible user input.
Why
Users enter dates like "Fall 2023" or "2020-09" for events. Strict dates (YYYY-MM-DD/YYYY-MM/YYYY) get validated via ISO parsing, while custom text passes through for template rendering. ValueError from fromisoformat() propagates to Pydantic, which converts it into a specific user-friendly message (e.g., "The month must be between 1 and 12.").
Parameters:
-
date(int | str) –Date value to validate.
Returns:
-
int | str–Original date if valid.