I use the Saripaar validation library https://github.com/ragunathjawahar/android-saripaar to validate one of the forms. The library is quite useful because it avoids a large number of templates for validating the form. However, the library uses widget annotations. The following is an example:
@Password(order = 1) @TextRule(order = 2, minLength = 6, message = "Enter at least 6 characters.") private EditText passwordEditText;
The order attribute is the one that defines the order in which checks pass to take place. Here is my problem: the message attribute accepts a constant expression. I need to install this from a string resource file. Thus, error messages can be internationalized later. I already tried below:
message = getResources().getString(R.string.err_msg)
But it doesn't seem to work, as it needs compile-time constants.
Can someone help me with the same or guide me through a workaround?
Viren source share