Merge branches 'vasavk/inputStepper' and 'develop' of https://gitlab.verizon.com/BPHV_MIPS/vds_ios into vasavk/inputStepper
This commit is contained in:
commit
77325f0034
@ -72,16 +72,23 @@ public protocol Rule<ValueType> {
|
|||||||
func isValid(value: ValueType?) -> Bool
|
func isValid(value: ValueType?) -> Bool
|
||||||
/// Error Message to be show if the value is invalid.
|
/// Error Message to be show if the value is invalid.
|
||||||
var errorMessage: String { get }
|
var errorMessage: String { get }
|
||||||
|
/// type of rule
|
||||||
|
var ruleType: String { get }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Rule {
|
||||||
|
public var ruleType: String { "\(Self.self)" }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type Erased Rule for a specific ValueType.
|
/// Type Erased Rule for a specific ValueType.
|
||||||
public struct AnyRule<ValueType>: Rule {
|
public struct AnyRule<ValueType>: Rule {
|
||||||
private let _isValid: (ValueType?) -> Bool
|
private let _isValid: (ValueType?) -> Bool
|
||||||
|
public var ruleType: String
|
||||||
public let errorMessage: String
|
public let errorMessage: String
|
||||||
|
|
||||||
public init<R: Rule>(_ rule: R) where R.ValueType == ValueType {
|
public init<R: Rule>(_ rule: R) where R.ValueType == ValueType {
|
||||||
self._isValid = rule.isValid
|
self._isValid = rule.isValid
|
||||||
|
self.ruleType = rule.ruleType
|
||||||
self.errorMessage = rule.errorMessage
|
self.errorMessage = rule.errorMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user