EnterpriseDS Documentation

Structure DSMin​Max​Validation​Rule

public struct DSMinMaxValidationRule: DSValidationRule  

A validation rule for requiring that text is a number and is between a min and max value. (Inclusive.)

DSMinMaxValidationRule DSMinMaxValidationRule DSValidationRule DSValidationRule DSMinMaxValidationRule->DSValidationRule

Conforms To


A validation framework for defining how text entered into a DSTextField can be validated and an appropriate error message provided if that validation fails. Multiple DSValidationRule objects can stack to perform multiple validations including the special DSRequiredTextValidationRule which is the only built-in rule validates empty fields.



public init(min: Int, max: Int, message: String)  

Initializes the validation rule.


min Int

The smallest number allowed for the field. (Inclusive)

max Int

The largest number allowed for the field. (Inclusive)

message String

Error message to display if validator fails. Should include two %@ formatters for min and max.



public var errorMessage: String  

The error message to be displayed when validation fails.



public func isValid(_ text: String) -> Bool  

Valid if the number is between the min and max numbers provided. Valid if empty.