Blorm icon indicating copy to clipboard operation
Blorm copied to clipboard

Validating manually with no views attached with builder

Open mcassiano opened this issue 8 years ago • 5 comments

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?

mcassiano avatar Aug 22 '16 14:08 mcassiano

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.

bloderxd avatar Aug 23 '16 12:08 bloderxd

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.

mcassiano avatar Aug 23 '16 13:08 mcassiano

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.

bloderxd avatar Aug 23 '16 13:08 bloderxd

I think I can PR something. :)

mcassiano avatar Aug 23 '16 13:08 mcassiano

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.

bloderxd avatar Sep 04 '16 17:09 bloderxd