diff --git a/VDS/Protocols/FormFieldable.swift b/VDS/Protocols/FormFieldable.swift index 82666772..e5e6894c 100644 --- a/VDS/Protocols/FormFieldable.swift +++ b/VDS/Protocols/FormFieldable.swift @@ -72,16 +72,23 @@ public protocol Rule { func isValid(value: ValueType?) -> Bool /// Error Message to be show if the value is invalid. 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. public struct AnyRule: Rule { private let _isValid: (ValueType?) -> Bool - + public var ruleType: String public let errorMessage: String public init(_ rule: R) where R.ValueType == ValueType { self._isValid = rule.isValid + self.ruleType = rule.ruleType self.errorMessage = rule.errorMessage }