EnterpriseDS Documentation

Structure DSMax​Text​Length​Validation​Rule

public struct DSMaxTextLengthValidationRule: DSValidationRule  

A validation rule for capping the length of the text to a maximum amount.

DSMaxTextLengthValidationRule DSMaxTextLengthValidationRule DSValidationRule DSValidationRule DSMaxTextLengthValidationRule->DSValidationRule

Conforms To

DSValidationRule

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.

Initializers

init(max​Text​Length:​message:​)

public init(maxTextLength: Int = 500, message: String)  

Initializer.

Parameters

max​Text​Length Int

The maximum number of characters allowed

Properties

error​Message

public private(set) var errorMessage: String

The error message to be displayed when validation fails.

Methods

is​Valid(_:​)

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

Valid if the number of characters is less than the maximum amount allowed.