- Add resolve_constraints_in_content() to handle ${constraint.path} patterns
- Integrate into all form loading functions (load_from_file, load_fragment_form, etc)
- Support nested path navigation (e.g., constraints.tracker.udp.max_items)
- Add test_constraint_interpolation() test
fix(nickel-roundtrip): apply constraint interpolation in roundtrip workflow
- Fix execute_form() to use load_from_file() instead of parse_toml()
- Ensures constraints are resolved in roundtrip mode
docs(examples): add constraint interpolation example
- Create examples/05-fragments/constraints.toml
- Update examples/05-fragments/array-trackers.toml to use ${constraint.*}
- Document constraint workflow in examples/05-fragments/README.md
Benefits:
- Single source of truth for validation limits
- Forms auto-resolve constraints at load time
- All layers (Forms, Nickel, Templates) sync automatically
103 lines
2.4 KiB
TOML
103 lines
2.4 KiB
TOML
name = "Tracker Configuration with Arrays"
|
|
description = "Example showing RepeatingGroup arrays for multiple trackers"
|
|
display_mode = "complete"
|
|
|
|
# Header
|
|
[[elements]]
|
|
name = "main_header"
|
|
type = "section_header"
|
|
title = "🎯 Tracker Configuration"
|
|
border_top = true
|
|
border_bottom = true
|
|
|
|
# Introduction
|
|
[[elements]]
|
|
name = "intro"
|
|
type = "section"
|
|
content = "Configure multiple UDP and HTTP tracker listeners. You can add, edit, or delete trackers as needed."
|
|
|
|
# Tracker mode selection
|
|
[[elements]]
|
|
name = "tracker_mode"
|
|
type = "select"
|
|
prompt = "Tracker Mode"
|
|
required = true
|
|
options = [
|
|
{ value = "public", label = "Public Tracker" },
|
|
{ value = "private", label = "Private Tracker" },
|
|
]
|
|
default = "public"
|
|
order = 1
|
|
|
|
# UDP Trackers array
|
|
# max_items loaded from constraints.toml via constraint interpolation
|
|
# See constraints.toml to change max_items (default: 4)
|
|
[[elements]]
|
|
name = "udp_trackers"
|
|
type = "repeatinggroup"
|
|
prompt = "UDP Tracker Listeners"
|
|
fragment = "fragments/tracker-udp-item.toml"
|
|
min_items = 0
|
|
max_items = "${constraint.tracker.udp.max_items}"
|
|
default_items = 1
|
|
unique = true
|
|
required = false
|
|
help = "Add UDP tracker listener addresses (must be unique). Standard BitTorrent port is 6969."
|
|
order = 2
|
|
|
|
# HTTP Trackers array
|
|
# max_items loaded from constraints.toml via constraint interpolation
|
|
# See constraints.toml to change max_items (default: 4)
|
|
[[elements]]
|
|
name = "http_trackers"
|
|
type = "repeatinggroup"
|
|
prompt = "HTTP Tracker Listeners"
|
|
fragment = "fragments/tracker-http-item.toml"
|
|
min_items = 0
|
|
max_items = "${constraint.tracker.http.max_items}"
|
|
default_items = 1
|
|
unique = true
|
|
required = false
|
|
help = "Add HTTP tracker listener addresses (must be unique). Standard HTTP port is 80, HTTPS is 443."
|
|
order = 3
|
|
|
|
# API Configuration section
|
|
[[elements]]
|
|
name = "api_header"
|
|
type = "section_header"
|
|
title = "📡 API Configuration"
|
|
border_top = true
|
|
border_bottom = true
|
|
|
|
# API Token
|
|
[[elements]]
|
|
name = "api_token"
|
|
type = "password"
|
|
prompt = "Admin API Token"
|
|
required = true
|
|
help = "Secure token for API authentication"
|
|
order = 4
|
|
|
|
# API Port
|
|
[[elements]]
|
|
name = "api_port"
|
|
type = "text"
|
|
prompt = "API Port"
|
|
placeholder = "1212"
|
|
default = "1212"
|
|
required = true
|
|
order = 5
|
|
|
|
# Summary
|
|
[[elements]]
|
|
name = "summary_header"
|
|
type = "section_header"
|
|
title = "✅ Configuration Summary"
|
|
border_top = true
|
|
|
|
[[elements]]
|
|
name = "summary"
|
|
type = "section"
|
|
content = "Review your tracker configuration above. Click submit to save settings."
|
|
order = 6
|