ragunathjawahar / android-saripaar

UI form validation library for Android
Apache License 2.0
3.22k stars 460 forks source link

SaripaarViolationException #225

Open Savrov opened 6 years ago

Savrov commented 6 years ago

I have a code inside androidx.fragment.app.Fragment

@Password(min = 3)
EditText etPassword;

After init validation

validator = new Validator(this);
validator.setValidationMode(Validator.Mode.IMMEDIATE);
validator.setValidationListener(this);

And on validator.validate(); I receive:

SaripaarViolationException: 'com.mobsandgeeks.saripaar.rule.PasswordRule' should have a single-argument constructor that accepts a 'com.mobsandgeeks.saripaar.annotation.Password' instance.

Pls help to fix

Asad-Khan-Aasanjobs commented 6 years ago

@Savrov

I'm getting this error as well.

IMO It is most probably because of the instantiateRule() method in Reflector.java class, which throws this violation error when trying to create the validation rule with any available public constructors through reflection.

I tried debugging this and found that no constructors are returned, even after adding a public constructor to my Annotation Rule class.

This only happens when I'm using proguard, but I've added these lines to my proguard.pro file: -keep class com.mobsandgeeks.saripaar.** {*;} -dontwarn com.mobsandgeeks.saripaar.** Still this is happening. Can some help here?

Savrov commented 6 years ago

@Asad-Khan-Aasanjobs I have created new project with AndroidX support (again) and it works. In old project its not still working.

Its smth with project build...