53 lines
1.5 KiB
Plaintext
53 lines
1.5 KiB
Plaintext
|
|
# Common Constraints and Validation Rules
|
||
|
|
|
||
|
|
let limits = import "../values/limits.ncl" in
|
||
|
|
let ranges = import "../values/ranges.ncl" in
|
||
|
|
|
||
|
|
{
|
||
|
|
# Port constraints
|
||
|
|
valid_port = fun port =>
|
||
|
|
port >= limits.port.min && port <= limits.port.max,
|
||
|
|
|
||
|
|
# Valid log level constraint
|
||
|
|
valid_log_level = fun level =>
|
||
|
|
std.array.contains ranges.log_levels level,
|
||
|
|
|
||
|
|
# Valid auth method
|
||
|
|
valid_auth_method = fun method =>
|
||
|
|
std.array.contains ranges.auth_methods method,
|
||
|
|
|
||
|
|
# Valid storage backend
|
||
|
|
valid_storage_backend = fun backend =>
|
||
|
|
std.array.contains ranges.storage_backends backend,
|
||
|
|
|
||
|
|
# Valid deployment mode
|
||
|
|
valid_deployment_mode = fun mode =>
|
||
|
|
std.array.contains ranges.deployment_modes mode,
|
||
|
|
|
||
|
|
# Valid LLM provider
|
||
|
|
valid_llm_provider = fun provider =>
|
||
|
|
std.array.contains ranges.llm_providers provider,
|
||
|
|
|
||
|
|
# Budget threshold constraint (0-100)
|
||
|
|
valid_budget_threshold = fun percent =>
|
||
|
|
percent >= 0 && percent <= 100,
|
||
|
|
|
||
|
|
# Worker count constraint
|
||
|
|
valid_worker_count = fun count =>
|
||
|
|
count >= limits.workers.min && count <= limits.workers.max,
|
||
|
|
|
||
|
|
# Connection count constraint
|
||
|
|
valid_connection_count = fun count =>
|
||
|
|
count >= limits.connections.min,
|
||
|
|
|
||
|
|
# URL format validation (basic)
|
||
|
|
valid_url = fun url =>
|
||
|
|
std.string.length url > 0 && (
|
||
|
|
std.string.starts_with "http://" url
|
||
|
|
|| std.string.starts_with "https://" url
|
||
|
|
|| std.string.starts_with "ws://" url
|
||
|
|
|| std.string.starts_with "wss://" url
|
||
|
|
|| std.string.starts_with "file://" url
|
||
|
|
),
|
||
|
|
}
|