LengthConstraint

public struct LengthConstraint : Constraint

A constraint to validate if a value is with a valid length.

  • min

    A default minimum value to set if no minimum value is provided.

    Declaration

    Swift

    public static let min: UInt
  • max

    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
  • min

    A custom minimum value.

    Declaration

    Swift

    public let min: UInt
  • max

    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 LengthValidator 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 Groups to group by.

    Declaration

    Swift

    public init(exact: UInt, 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 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

    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 Groups to group by. Defaults to an empty set.