Some checks failed
Rust CI / Security Audit (push) Has been cancelled
Rust CI / Check + Test + Lint (nightly) (push) Has been cancelled
Rust CI / Check + Test + Lint (stable) (push) Has been cancelled
mdBook Build & Deploy / Build mdBook (push) Has been cancelled
Nickel Type Check / Nickel Type Checking (push) Has been cancelled
mdBook Build & Deploy / Documentation Quality Check (push) Has been cancelled
mdBook Build & Deploy / Deploy to GitHub Pages (push) Has been cancelled
mdBook Build & Deploy / Notification (push) Has been cancelled
1.7 KiB
1.7 KiB
Platform Constraints
Validation rules and predicates for configuration values.
Constraint Files
Common (common.ncl)
General validation rules applicable to all services:
Port constraints:
valid_port(port)- Check if port is in valid range (1024-65535)
String enumeration constraints:
valid_log_level(level)- Check against valid log levelsvalid_auth_method(method)- Check against valid auth methodsvalid_storage_backend(backend)- Check against valid backendsvalid_deployment_mode(mode)- Check against deployment modesvalid_llm_provider(provider)- Check against LLM providers
Numeric constraints:
valid_budget_threshold(percent)- Check percentage is 0-100valid_worker_count(count)- Check worker count is in rangevalid_connection_count(count)- Check connection count is valid
URL constraints:
valid_url(url)- Check URL has valid protocol scheme
Usage Pattern
let constraints = import "constraints/common.ncl" in
# Validate port
assert constraints.valid_port 8080
# Validate enum
assert constraints.valid_log_level "debug"
# In a record definition (using Nickel contracts)
{
port | Number | doc "Server port" | {
predicate = fun p => constraints.valid_port p,
label = "valid port range"
} = 8080
}
Constraint Philosophy
Constraints are predicates - functions that return true/false for validation:
- Used in Nickel's contract system:
field | Type | {predicate = constraint_fn} - Enable gradual validation - catch errors at config generation time
- Prevent invalid configurations reaching runtime
- Document valid value ranges inline
References
- Parent:
../README.md - Validators:
../validators/README.md - Values:
../values/README.md