CodexPolicy
Immutable configuration for content validation and normalization.
Overview
The CodexPolicy dataclass defines the rules for how content titles, tags, and categories should be handled within the system. It ensures data consistency through strict validation rules and normalization flags.
@dataclass(frozen=True)
This class is immutable. Once an instance is created, its attributes cannot be modified, making it thread-safe and reliable for policy injection.
Title Configuration
Settings related to title validation and formatting.
| Attribute | Type | Default | Description |
|---|---|---|---|
title_required |
boolean | True |
Specifies if a title must be provided. |
title_unique |
boolean | True |
Ensures no two items share the same title. |
title_max_length |
int | 150 |
Maximum allowed characters for the title. |
title_strip |
boolean | True |
Removes leading/trailing whitespace automatically. |
Category Configuration
Handles the "Taxonomy"—the structural and organizational hierarchy.
| Attribute | Type | Default | Description |
|---|---|---|---|
category_required |
boolean | True |
Mandates that every item must belong to a category. |
category_default |
string | "General" |
The fallback category name if none is provided. |
category_capitalize |
boolean | True |
Ensures the first letter of the category is uppercase. |
category_max_length |
int | 50 |
Restricts category names to a specific length. |