LengthValidation

public protocol LengthValidation: Validation where Supported: Collection

A validation type that verifies the length of a type conforming to Collection.

internal struct LengthRange10To1028<C>: LengthValidation where C: Collection {
    typealias Supported = C

    static var maxLength: Int { return 1028 }
    static var minLength: Int { return  10 }
}

If the value passed into the validate method has a length the is greater than maxLength, ValidationError.lengthTooLong is thrown. If the value has a length less than minLength, ValidationError.lengthTooShort is thrown.

  • The maximum length that the validated collection can have.

    Declaration

    Swift

    static var maxLength: Int
  • The minimum length that the validated collection can have.

    This value defaults to 0.

    Declaration

    Swift

    static var minLength: Int