I'm using Moya
+ Alamofire
and I'm trying to validate every request (like Alamofire.request(.GET, "https://httpbin.org/get").validate()
) but within Moya
.
But I can not find a way to do this.
This is possible now after you implement validate
property on your TargetType
implementation as described in this example:
// MARK: - TargetType Protocol Implementation
extension MyService: TargetType {
// ...
// Validate setup is not required; defaults to `false`
// for all requests unless specified otherwise.
var validate: Bool {
switch self {
case .showUser, .showAccounts:
return true
case .createUser:
return false
}
}
}