Arsen Arsen - 1 year ago 119
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.

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download