Blorm
Blorm copied to clipboard
Validating manually with no views attached with builder
Hey! Thanks for the great work with Blorm.
It seems that the builder doesn't return an instance of a Blorm object any time before submitOn is called. I think it's a good idea to have a .build() method that returns an instance for a Blorm instance so we can call .onSubmitted() manually. What do you think?
Why would you like to call onSubmitted manually? if you call this function without set those builder values, it will return you null pointer exception.
Having the need to call .submitOn() on a view sort of limits the developer to attach the validation to something that will trigger it in the UI. In the current setting, it's not possible to validate your fields programmatically, like in https://github.com/ragunathjawahar/android-saripaar (validator.validate()). What I would suggest is having a new method in the builder Class (maybe .build()) that will return an instance of blorm (like in Blorm.java:119), so you can trigger validation of the fields which ever way you want.
Ok, I'm out of time at the moment but when I got it, I can implement it, or you can fork this project and do it.
I think I can PR something. :)
I made some changes in blorm class to support what you said, go to validate-yourself branch in Blorm.java:64 to see and tell me if it fix your problem.