|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
Thrown by schemaJson<A>() when A's declared formRules contradict A's own derived required array so completely that no submission could satisfy both. More...
#include <forms.hpp>
Public Member Functions | |
| UnsatisfiableFormError (std::string_view actionName, std::string_view ruleKind, std::string_view requiredFields) | |
| Constructs the error with a message naming the action type, the offending rule kind, and the fields that are both required and capped by it. | |
Thrown by schemaJson<A>() when A's declared formRules contradict A's own derived required array so completely that no submission could satisfy both.
The one contradiction that is decidable from the two halves alone: a rule that caps how many of the fields it ranges over may be engaged at once (exactlyOneOf, mutuallyExclusive — never atLeastOneOf, which is a floor and can always be met by engaging everything) ranging over two or more fields that required also demands. required says "fill in both"; the rule says "at most one"; the form is dead on arrival.
This is a programming error in the action's declaration, not a runtime condition — hence std::logic_error, and hence a throw rather than the silent tolerance schema generation extends to a formLayout entry naming an unknown field. The fix is to name the rule's fields in A::optionalFields (the rule is then the only gate on them) or to drop the rule.
|
inline |
Constructs the error with a message naming the action type, the offending rule kind, and the fields that are both required and capped by it.
| actionName | The action type's name (glz::name_v<A>). |
| ruleKind | The offending rule's wire "kind" string, e.g. "exactlyOneOf". |
| requiredFields | Comma-separated wire names of the fields that are in required and ranged over by the rule. |