10. Require a field only when another is present
reason is meaningless without stage_id. You want "if stage_id is provided, reason becomes required" โ without making either unconditionally required.
Problem. reason is meaningless without stage_id. You want "if stage_id is provided, reason becomes required" โ without making either unconditionally required.
Solution. @depends_on(:other_field). It emits JSON Schema dependentRequired.
#: (
#: workflow_id: String,
#: ?stage_id: String? @requires(:backward_routing) @depends_on(:workflow_id),
#: ?reason: String? @requires(:backward_routing) @depends_on(:stage_id)
#: ) -> Hash[Symbol, untyped]Result. For a manager, the schema includes:
{ "dependentRequired": { "workflow_id": ["stage_id"], "stage_id": ["reason"] } }Note both fields are also gated by @requires โ tags stack and AND together. An operator sees neither field nor the dependency.
Collected from COOKBOOK.md in the repository. Edit it there, not here.