Arsen Arsen - 1 month ago 12
Swift Question

Moya + Alamofire validate every request

I'm using

and I'm trying to validate every request (like
Alamofire.request(.GET, "").validate()
) but within

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