SwiftValidatorCommunity/SwiftValidator

Allow validation depending on other fields

ldiqual opened this issue · 3 comments

Here's the case I'm thinking about:
Two text fields: "driving license state", "driving license number". Validating a driving license number depends on the value of the driving license state, and there's no way to specify that at the moment.

I'm not too sure what the interface should be for such a case. Maybe something like this:

validator.addField(stateField, rules: [RequiredRule()])
validator.addField(licenseNumberField, rules: [RequiredRule(), DynamicRule({ value -> Bool in
    guard let state = stateField.text else {
        return false
    }
    return validateLicenseNumber(value, state: state)
})])

+1 for this. I wrote a custom rule to handle validating that two password fields are equal and it works just not as great as I would like it to since it only shows one field as failing validation right now. Would be nice when they fail both show the error and when they pass both clear the error display.

+1

I'm not going to lie this project took off and I'm pretty overwhelmed by it. I no longer actively code in Swift and I need help from more contributors in order to keep this project relevant. I'd like to find someone to transition as lead maintainer or help this codebase find a happy home with a company.

The codebase for this project is relatively small and focused project for who is looking to contribute. It does one thing, and does it pretty well. It has pretty high test coverage and good adoption. I think my ideal maintainer / contributor would work for a company that actively uses SwiftValidator in their production application.

If you're interested in helping out please comment on #204