RangeRule

public class RangeRule<V> : ValidationRule<V> where V : Comparable, V : CustomStringConvertible

RangeRule is a subclass of ValidationRule that defines how value is validated with min & max limits.

  • Initializes a RangeRule object to verify that quantity of value is in the range of min & max.

    Declaration

    Swift

    public init(min: V, max: V, message: String? = nil)

    Parameters

    min

    Minimum required quantity of value.

    max

    Maximum required quantity of value.

    message

    String of error message.

    Return Value

    An initialized object.

  • Method used to validate the provided value.

    Declaration

    Swift

    public override func validate(_ value: V?) -> String?

    Parameters

    value

    Any value to be checked for validation.

    Return Value

    Error Message. nil if validation is successful; String if validation fails.