Structure
DSAdHocValidationRule
public struct DSAdHocValidationRule: DSValidationRule
A validation rule that allows for an error message to be expressly set. When the message is non-empty, the validation fails. This validation rule is useful for showing backend errors.
Relationships
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(message:)
public init(message: String? = nil)
Initializes the validation rule.
Parameters
Name | Type | Description |
---|---|---|
message | String? |
Error message to display and forces validation to fail |
Properties
Methods
isValid(_:)
public func isValid(_ text: String) -> Bool
Fails validation if an error message has been set.