contracts.rules_forms

Page actions AI-ready formats and sharing
Open LLM text
Share with AI
Ask Claude Ask ChatGPT Ask Gemini Ask Copilot

Form-related extraction and validation helpers.

Form-related extraction and validation helpers.

contracts.rules_forms

Name Type Default Description
type —
qualified_name —
element_type —
description —
source_file —
line_number —
is_autodoc —
autodoc_element —
_autodoc_template —
_autodoc_url_path —
_autodoc_page_type —
title —
doc_content_hash —

Symbols on this page

extract_template_block_source
function
def extract_template_block_source(source: str, block_name: str) -> str | None

Return source inside a named template block, respecting nested tags.

This is intentionally a small structural scanner instead of a full template parser. Form contracts only need the body of{% block name %}, but a regex stops at the first nested{% endblock %}and misses fields later in the block.

Parameters

Name Type Default Description
source str —
block_name str —
extract_form_field_names
function
def extract_form_field_names(source: str) -> set[str]

Extract form field names from input/select/textarea tags.

Parameters

Name Type Default Description
source str —
validate_form_contracts
function
def validate_form_contracts(result, router, template_sources: dict[str, str]) -> list[ContractIssue]

Validate dataclass-backed form contracts against template fields.

Parameters

Name Type Default Description
result —
router —
template_sources dict[str, str] —

View source · /home/runner/work/chirp/chirp/site/../src/chirp/contracts/rules_forms.py:1