IntegerConstraint
public struct IntegerConstraint : Constraint
A constraint to validate if a value is an integer number.
-
A default minimum value to set if no minimum value is provided.
Declaration
Swift
public static let min: Int
-
A default maximum value to set if no maximum value is provided.
Declaration
Swift
public static let max: Int
-
A default error message to show for a minimum value violation.
Declaration
Swift
public static let minMessage: String
-
A default error message to show for a maximum value violation.
Declaration
Swift
public static let maxMessage: String
-
A default error message to show for an exact value violation.
Declaration
Swift
public static let exactMessage: String
-
A custom minimum value.
Declaration
Swift
public let min: Int
-
A custom maximum value.
Declaration
Swift
public let max: Int
-
A custom error message to show for a minimum value violation.
Declaration
Swift
public let minMessage: String
-
A custom error message to show for a maximum value violation.
Declaration
Swift
public let maxMessage: String
-
A custom error message to show for an exact value violation.
Declaration
Swift
public let exactMessage: String
-
See
Constraint
.Declaration
Swift
public let groups: Set<Group>
-
A validator named
IntegerValidator
to validate a value.Declaration
Swift
public let validator: ConstraintValidator
-
Initializes a new instance with an exact value, custom error message, and a set of
Group
s to group by.Declaration
Swift
public init(exact: Int, exactMessage: String = exactMessage, groups: Set<Group> = .init())
Parameters
exact
An exact value.
exactMessage
A custom error message to show for an exact value violation. Defaults to the default exact value violation error message.
groups
A set of
Group
s to group by. Defaults to an empty set. -
Initializes a new instance with minimum/maximum values, custom minimum/maximum error messages, and a set of
Group
s to group by.Declaration
Swift
public init( min: Int = min, max: Int = max, minMessage: String = minMessage, maxMessage: String = maxMessage, exactMessage: String = exactMessage, groups: Set<Group> = .init() )
Parameters
min
A custom minimum value. Defaults to the default minimum value.
max
A custom maximum value. Defaults to the default maximum value.
minMessage
A custom error message to show for a minimum value violation. Defaults to the default minimum value violation error message.
maxMessage
A custom error message to show for a maximum value violation. Defaults to the default maximum value violation error message.
exactMessage
A custom error message to show for an exact value violation. Defaults to the default exact value violation error message.
groups
A set of
Group
s to group by. Defaults to an empty set.