Quiver
Quiver copied to clipboard
[BUG]Can't create custom validator.
As of October 2019, I can't create a custom validator inheriting from Validator
. It seems the validate function is not declared as open, but public. When I try to subclass it and implement a custom validate function, I get the following error:
Overriding non-open instance method outside of its defining module
@heitorgcosta @LucianoPAlmeida would you kindly fix this?
I will proceed to open a pull request with this change.
@affbedran Humm, now I'm understanding it better ... maybe a solution to create a custom validation that doesn't require an API change could be to use a custom closure-based validator. You can see an example here :))
@LucianoPAlmeida I see, but wouldn't that be more of a workaround? What if I need to implement a more robust validation? There are cases when subclassing is better.
I don't see as a workaround, more like some generic point customization, where you can do any kind of validation in a very easy way. I agree that maybe some few robuts validations e.g. zip code maybe better subclass, but most cases just a closure would be simple enough :))
I see what you mean by that, but I still think it should be the dev's choice. If a complex case arises, and subclassing is somehow needed, the developer is put between a rock and a hard place.