I'm having problems calling this method:
public struct Validation
{
public static func register<declaringT : Object, propertyT, contextT : Object>(keyPath: PartialKeyPath<declaringT>, closure: @escaping ValidatorClosure<declaringT, propertyT, contextT>)
{
…
}
…
}
The calling code is:
extension Person : StaticInitialisable
{
public static var staticInit: (() -> ())? =
{
Validation.register(keyPath: \Person.name)
{
owner, args, context in
if args.newValue == nil
{
args.Message = "The name of a Person cannot be nil. Do you wish to continue?";
args.ErrorSeverity = ValidationErrorSeverity.Confirm;
}
}
}
}
I was hoping that, by passing a PartialKeyPath to the receiving method, it would be enough to infer the type.
I even explicitly typed the input parameters to the closure in the hope that that would work but, no joy.
extension Person : StaticInitialisable
{
public static var staticInit: (() -> ())? =
{
Validation.register(keyPath: \Person.name)
{
(owner: Person, args, context: Person) -> ()
if args.newValue == nil
{
args.Message = "The name of a Person cannot be nil. Do you wish to continue?";
args.ErrorSeverity = ValidationErrorSeverity.Confirm;
}
}
}
}
Any ideas please?