ConstraintType

public enum ConstraintType

A simplified API for the existing Constraints.

  • Creates a AndConstraint type with an array of child constraints and validation groups to be applied.

    Declaration

    Swift

    case and(_: [Constraint], groups: Set<Group> = .init())

    Parameters

    constraints

    An array of child constraints.

    groups

    Validation groups to be applied. Defaults to an empty array.

  • Creates a BlankConstraint type with a custom error message and validation groups to be applied.

    Declaration

    Swift

    case blank(_: String = BlankConstraint.message, groups: Set<Group> = .init())

    Parameters

    message

    A custom error message. Defaults to a default error message.

    groups

    Validation groups to be applied. Defaults to an empty array.

  • Creates an EmailConstrainttype with a custom error message and validation groups to be applied.

    Declaration

    Swift

    case email(_: String = EmailConstraint.message, groups: Set<Group> = .init())

    Parameters

    message

    A custom error message. Defaults to a default error message.

    groups

    Validation groups to be applied. Defaults to an empty array.

  • Creates an IntegerConstrainttype with minimum/maximum values, custom minimum/maximum error messages, and validation groups to be applied.

    Declaration

    Swift

    case integer(
        min: Int = IntegerConstraint.min,
        max: Int = IntegerConstraint.max,
        minMessage: String = IntegerConstraint.minMessage,
        maxMessage: String = IntegerConstraint.maxMessage,
        exactMessage: String = IntegerConstraint.exactMessage,
        groups: Set<Group> = .init()
    )

    Parameters

    min

    A custom minimum value. Defaults to a default minimum value.

    max

    A custom maximum value. Defaults to a default maximum value.

    minMessage

    A custom error message to show for a minimum value violation. Defaults to a default minimum value violation error message.

    maxMessage

    A custom error message to show for a maximum value violation. Defaults to a default maximum value violation error message.

    exactMessage

    A custom error message to show for an exact value violation. Defaults to a default exact value violation error message.

    groups

    Validation groups to be applied. Defaults to an empty array.

  • Creates an IPConstrainttype with a custom error message and validation groups to be applied.

    Declaration

    Swift

    case ip(_: String = IPConstraint.message, groups: Set<Group> = .init())

    Parameters

    message

    A custom error message. Defaults to a default error message.

    groups

    Validation groups to be applied. Defaults to an empty array.

  • Creates a JSONConstraint type with a custom error message and validation groups to be applied.

    Declaration

    Swift

    case json(_: String = JSONConstraint.message, groups: Set<Group> = .init())

    Parameters

    message

    A custom error message. Defaults to a default error message.

    groups

    Validation groups to be applied. Defaults to an empty array.

  • Creates a LengthConstraint type with minimum/maximum values, custom minimum/maximum error messages, and validation groups to be applied.

    Declaration

    Swift

    case length(
        min: UInt = LengthConstraint.min,
        max: UInt = LengthConstraint.max,
        minMessage: String = LengthConstraint.minMessage,
        maxMessage: String = LengthConstraint.maxMessage,
        exactMessage: String = LengthConstraint.exactMessage,
        groups: Set<Group> = .init()
    )

    Parameters

    min

    A custom minimum value. Defaults to a default minimum value.

    max

    A custom maximum value. Defaults to a default maximum value.

    minMessage

    A custom error message to show for a minimum value violation. Defaults to a default minimum value violation error message.

    maxMessage

    A custom error message to show for a maximum value violation. Defaults to a default maximum value violation error message.

    exactMessage

    A custom error message to show for an exact value violation. Defaults to a default exact value violation error message.

    groups

    Validation groups to be applied. Defaults to an empty array.

  • Creates a NotBlankConstraint type with a custom error message and validation groups to be applied.

    Declaration

    Swift

    case notBlank(_: String = NotBlankConstraint.message, groups: Set<Group> = .init())

    Parameters

    message

    A custom error message. Defaults to a default error message.

    groups

    Validation groups to be applied. Defaults to an empty array.

  • Creates a OrConstraint type with an array of child constraints and validation groups to be applied.

    Declaration

    Swift

    case or(_: [Constraint], groups: Set<Group> = .init())

    Parameters

    constraints

    An array of child constraints.

    groups

    Validation groups to be applied. Defaults to an empty array.

  • Creates a RegexConstraint type with a custom error message and validation groups to be applied.

    Declaration

    Swift

    case regex(_: String = RegexConstraint.message, groups: Set<Group> = .init())

    Parameters

    message

    A custom error message. Defaults to a default error message.

    groups

    Validation groups to be applied. Defaults to an empty array.

  • Creates a URLConstraint type with a file URL flag, a custom error message, and validation groups to be applied.

    Declaration

    Swift

    case url(_: String = URLConstraint.message, isFileURL: Bool, groups: Set<Group> = .init())

    Parameters

    message

    A custom error message. Defaults to a default error message.

    isFileURL

    Indicates whether it is a file URL or not. Defaults to false.

    groups

    Validation groups to be applied. Defaults to an empty array.

  • Creates a UUIDConstraint type with a custom error message and validation groups to be applied.

    Declaration

    Swift

    case uuid(_: String = UUIDConstraint.message, groups: Set<Group> = .init())

    Parameters

    message

    A custom error message. Defaults to a default error message.

    groups

    Validation groups to be applied. Defaults to an empty array.

  • Creates a VINConstraint with a custom error message and validation groups to be applied.

    Declaration

    Swift

    case vin(_: String = VINConstraint.message, groups: Set<Group> = .init())

    Parameters

    message

    A custom error message. Defaults to a default error message.

    groups

    Validation groups to be applied. Defaults to an empty array.

  • A matching Constraint for a ConstraintType.

    Declaration

    Swift

    public var constraint: Constraint { get }