morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::forms::UnsatisfiableFormError Struct Reference

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>

Inheritance diagram for morph::forms::UnsatisfiableFormError:

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.

Detailed Description

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.

Definition at line 2006 of file forms.hpp.

Constructor & Destructor Documentation

◆ UnsatisfiableFormError()

morph::forms::UnsatisfiableFormError::UnsatisfiableFormError ( std::string_view actionName,
std::string_view ruleKind,
std::string_view requiredFields )
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.

Parameters
actionNameThe action type's name (glz::name_v<A>).
ruleKindThe offending rule's wire "kind" string, e.g. "exactlyOneOf".
requiredFieldsComma-separated wire names of the fields that are in required and ranged over by the rule.

Definition at line 2015 of file forms.hpp.


The documentation for this struct was generated from the following file: