Created Failable[keyPath:] subscript
This commit is contained in:
parent
7795c0fb3e
commit
c18712a618
|
@ -35,6 +35,13 @@ public struct Failable<T, Validations> where Validations: Validation, Validation
|
|||
try self <~ t
|
||||
}
|
||||
|
||||
/// Gets the value of a property of the `value` property using a key path.
|
||||
///
|
||||
/// - Parameter path: The key path of the property to get from the `value` property.
|
||||
public subscript<Value>(keyPath path: KeyPath<T, Value>) -> Value {
|
||||
return self.value[keyPath: path]
|
||||
}
|
||||
|
||||
internal func validate(_ value: T)throws {
|
||||
try Validations.validate(value)
|
||||
try Validations.safeSubvalidations.forEach { validation in try validation.validate(value) }
|
||||
|
|
Loading…
Reference in New Issue