How can one require at least one field in a group of fields on a dataclass to be set to a truthy value? Does this require a custom root validator method as it requires looking at many fields at once? For example, consider the following dataclass:
@dataclass
class MyModel:
field1: Optional[str]: None
field2: Optional[str]: None
field3: Optional[str]: None
How could one require at least one of these three fields (field1
, field2
, or field3
) to be set to a non-empty string? Is there some built-in way to specify at least one field must be non-nil/empty (besides a custom root validator)?