ChoiceConstraint
public struct ChoiceConstraint : Constraint
A constraint to validate if a value exists in predefined choices.
-
A default error message to show if no custom error message is provided.
Declaration
Swift
public static let message: String
-
A list of choices.
Declaration
Swift
public let choices: [any Encodable & Equatable]
-
A custom error message.
Declaration
Swift
public let message: String
-
See
Constraint
.Declaration
Swift
public let groups: Set<Group>
-
A validator named
ChoiceValidator
to validate a value.Declaration
Swift
public let validator: ConstraintValidator
-
Initializes a new instance with a list of choices, a custom error message and a set of
Group
s to group by.Declaration
Parameters
choices
A list of choices. Defaults to an empty array.
message
A custom error message. Defaults to the default error message.
groups
A set of
Group
s to group by. Defaults to an empty set.