LengthConstraint
public struct LengthConstraint : Constraint
A constraint to validate if a value is with a valid length.
-
A default minimum value to set if no minimum value is provided.
Declaration
Swift
public static let min: UInt -
A default maximum value to set if no maximum value is provided.
Declaration
Swift
public static let max: UInt -
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: UInt -
A custom maximum value.
Declaration
Swift
public let max: UInt -
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
LengthValidatorto validate a value.Declaration
Swift
public let validator: ConstraintValidator -
Initializes a new instance with an exact value, custom error message, and a set of
Groups to group by.Declaration
Swift
public init(exact: UInt, exactMessage: String = exactMessage, groups: Set<Group> = .init())Parameters
exactAn exact value.
exactMessageA custom error message to show for an exact value violation. Defaults to the default exact value violation error message.
groupsA set of
Groups 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
Groups to group by.Declaration
Swift
public init( min: UInt = min, max: UInt = max, minMessage: String = minMessage, maxMessage: String = maxMessage, exactMessage: String = exactMessage, groups: Set<Group> = .init() )Parameters
minA custom minimum value. Defaults to the default minimum value.
maxA custom maximum value. Defaults to the default maximum value.
minMessageA custom error message to show for a minimum value violation. Defaults to the default minimum value violation error message.
maxMessageA custom error message to show for a maximum value violation. Defaults to the default maximum value violation error message.
exactMessageA custom error message to show for an exact value violation. Defaults to the default exact value violation error message.
groupsA set of
Groups to group by. Defaults to an empty set.
View on GitHub
Install in Dash