ragunathjawahar / android-saripaar

UI form validation library for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fatal Exception: java.lang.NullPointerException

AliTaylor1 opened this issue · comments

I'm really struggling to recreate this validation issue where some somehow the ValidatorContext losses context.
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mobsandgeeks.saripaar.ValidationContext.setViewRulesMap(java.util.Map)' on a null object reference
at com.mobsandgeeks.saripaar.Validator.createRulesSafelyAndLazily(Validator.java:479)

have you solved it?

@AliTaylor1 @traitaodoc1994 @ragunathjawahar can you tell me how to solve it? I had the same problem.

Hey,
I found the solution around this. Compare your validator initialization with the bottom code snippet.
Validator validator = new Validator(this);
Always pass this as its controller reference. If you're trying to pass getContext()/requireContext() or getActivity()/requireActivity() then somehow It won't be able to figure out on which class you are try to associate your validator.

I hope it helps. Happy Coding! </>