Feature Request: Allow custom input validator
aminiz opened this issue · comments
I would like to subclass FORMInputValidator.
This will give us a lot of flexibility. Initially, I need to use it to limit users to certain regex like one that would require a number with 2 decimal digits.
Hi @aminiz,
This should already be possible, gonna put an example.
Damn, went on vacations and forgot about this. Sorry.
@3lvis No worries! I can do any work required for this (be it making an example or implementing something) as long as I know what to do :)
OK! Got the time to add a demo for it, sadly it only works for Objective-C validators.
Form checks for the field id and looks for a validator for it. So if your field id is "External" it will look for FORMExternalValidator, then use that to validate the field.
I added a field with id "branded" for the demo.
https://github.com/hyperoslo/Form/tree/master/Basic-Swift
I hope this works for you, otherwise let me know.
A few validators to be used as examples.
https://github.com/hyperoslo/Form/tree/master/Source/Validators
Thanks! I will try them now.
Both FormValidator and FormInputValidator work like a charm!