ValigatorProtocol
public protocol ValigatorProtocol
ValigatorProtocol is a protocol which declares the public interfaces on the Valigator. This service can use to validate single fields or a list of input fields.
-
Declares the validation strategy. This is a read only property, most cases the value is set in the initializer.
Declaration
Swift
var validationStrategy: ValidationStrategy { get }
-
The receiver’s delegate.
Declaration
Swift
var delegate: ValigatorDelegate? { get set }
-
The object that acts as the data source of the Valigator.
Declaration
Swift
var dataSource: ValigatorDataSource? { get set }
-
Returns true if the fields has been validated and are valid.
Declaration
Swift
var isAllFieldValid: Bool { get }
-
Register a validatable field. The order of registration will give the order of the input fields.
Declaration
Swift
func registerField<InputType, ValidationRule>(_ fieldModel: FieldValidationModel<InputType, ValidationRule>) where InputType == ValidationRule.InputType, ValidationRule : ValidationRuleProtocol
Parameters
fieldModel
model that describe field with generic type to define the type of the validatable value.
-
Register a validatable field before the specific field ID.
Declaration
Swift
func registerField<InputType, ValidationRule>(_ fieldModel: FieldValidationModel<InputType, ValidationRule>, before beforeId: Int) -> Bool where InputType == ValidationRule.InputType, ValidationRule : ValidationRuleProtocol
Parameters
fieldModel
model that describe field with generic type to define the type of the validatable value.
Return Value
true if the registration was successful, otherwise false
-
Register a validatable field after the specific field ID.
Declaration
Swift
func registerField<InputType, ValidationRule>(_ fieldModel: FieldValidationModel<InputType, ValidationRule>, after afterId: Int) -> Bool where InputType == ValidationRule.InputType, ValidationRule : ValidationRuleProtocol
Parameters
fieldModel
model that describe field with generic type to define the type of the validatable value.
Return Value
true if the registration was successful, otherwise false
-
Register a validatable crossfield.
Declaration
Swift
func registerCrossFieldValidationRule(crossFieldValidationRule: CrossFieldValidationRule)
Parameters
crossFieldValidationRule
a struct what declares the validation logic.
-
Validate a field by the given identifier.
Declaration
Swift
func validateFieldBy(id: Int)
Parameters
id
identifier of the validatable field.
-
Validate a field by the given index.
Declaration
Swift
func validateFieldBy(index: Int)
Parameters
index
index of the validatable field.
-
Validate all registered field.
Declaration
Swift
func validateAllField()
-
We have to call this function when the value of a field has been changed.
- eg.: this should be true when we are editing a textfield and false when we have finished.
Declaration
Swift
func editStateDidChanged(fieldId: Int, isActive: Bool)
Parameters
fieldId
identifier of the modified field.
isActive
a boolean what is refers to the active state of the field,
-
Reset validation state of a field by the given identifier.
Declaration
Swift
func resetValidationStateFor(fieldId: Int)
Parameters
id
identifier of the validatable field.
-
Enable/disable a field by the given identifier.
- eg.: this should be true when we would like to validate the field and false when not
Declaration
Swift
func setEnableFieldValidationBy(id: Int, enable: Bool)
Parameters
id
identifier of the validatable field.
enable
a boolean what refers to the ‘shouldValidate’ state of the field,
-
Get current field state.
Declaration
Swift
func fieldState(id: Int) -> FieldState?
Parameters
id
identifier of the field.
Return Value
FieldState