Eureka Forms Hide validation errors based on SegmentedRow

时间:2018-03-25 18:45:32

标签: ios swift generics enums eureka-forms

I am unable to hide the validation errors based on the value of each SegmentedRow (upon switching).

Edit: Eureka version 4.0.1

What I have tried: Switching over the val and comparing to each ImportSelectionType

I can hide them for an individual SegmentedRow value: code below.

 $0.hidden = Condition.function(["segment"], { form in
                        if let val = form.rowBy(tag: "segment")?.baseValue as? String {
                            // TODO: make it work in all cases
                            return val != ImportSelectionType.keystore.title
                        }

                        return false
                    })

How could I make this generic so it will work in all cases?

Edit: ImportSelectionType is declared like so. enum ImportSelectionType { case keystore case privateKey case mnemonic case watch

var title: String {
    switch self {
    case .keystore:
        return "Keystore"
    case .privateKey:
        return "Private Key"
    case .mnemonic:
        return "Mnemonic"
    case .watch:
        return "Watch"
    }
}

init(title: String?) {
    switch title {
    case ImportSelectionType.privateKey.title?:
        self = .privateKey
    case ImportSelectionType.watch.title?:
        self = .watch
    case ImportSelectionType.mnemonic.title?:
        self = .mnemonic
    default:
        self = .keystore
    }
}

}

1 个答案:

答案 0 :(得分:0)

似乎更新到Eureka 4.1.1解决了这个问题。