Search code examples
iosswiftgenericsenumseureka-forms

Eureka Forms Hide validation errors based on SegmentedRow


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
    }
}

}


Solution

  • It seems updating to Eureka 4.1.1 solved the issue.