android-saripaar icon indicating copy to clipboard operation
android-saripaar copied to clipboard

Fatal Exception: java.lang.NullPointerException

Open AliTaylor1 opened this issue 6 years ago • 3 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)

AliTaylor1 avatar Feb 16 '18 10:02 AliTaylor1

have you solved it?

traitaodoc1994 avatar Jul 26 '18 03:07 traitaodoc1994

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

xionger0520 avatar Sep 04 '18 07:09 xionger0520

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! </>

Puneet1796 avatar Jun 02 '20 11:06 Puneet1796