Richard Sundqvist
12/12/2025, 7:50 AM@model_validator.Marvin
12/12/2025, 7:50 AMMarvin
12/12/2025, 7:54 AM@model_validator logic.
- JSON Schema can handle many constraints (type, range, length, enums, dependentRequired/if-then-else), but not arithmetic across fields like a sum-equals-1 rule.
Docs/refs:
- Form building with Pydantic/JSON Schema
- Pass inputs to workflows
- The UI validation endpoint (used by the form) is documented here: prefect.server.api.ui.schemas
Workarounds you can consider:
- Normalize in your flow: accept non-normalized weights (constrain each value with JSON Schema: min/max, item count) and normalize to sum to 1.0 at the start of the run.
- Fail fast at start: keep your Pydantic @model_validator and raise immediately; the run will exit almost instantly and still avoid doing any expensive work.
- If you truly need to block before any run is created, you’d need a custom frontend or service that evaluates your aggregation rule before invoking Prefect — the built-in UI isn’t extensible for custom client-side logic today.
If you share your exact parameter shape, I can suggest the strongest JSON Schema constraints the UI can enforce up front and a minimal “fail fast” pattern for anything it can’t.