3

I am trying to validate a form with mixed data type inputs from user. I also have Optional/Required field along with Regex validations. I have implemented Android Data binding using MVVM and hence I can now not use saripar.

I tried Kubwa but i can not use duplicate annotations there. I have also had a look at android-binding,but I couldn't implement the library and also they don't support it anymore. Let me know if anyone can suggest better approach.

1 Answer 1

2

if by "duplicate annotations" you mean multiple of the same type (2 or more @Email validations) - then Kubwa will work. All the annotations have a .List sub annotation for such situations:

@NotNull.List({
    @NotNull(name = "streetError", errorMessage = R.string.streetError),
    @NotNull(name = "cityError", errorMessage = R.string.cityError),
    @NotNull(name = "countryError", errorMessage = R.string.countryError)
})

Disclaimer - Kubwa is my library :)

Sign up to request clarification or add additional context in comments.

6 Comments

i really like your library but have tried very hard to set it up to no avail.can you please help me
@Pamparanpa - what issues are you having?
@Boots have you tried that in Kotlin? It says "An annotation can't be used as the annotations argument"
Solved: Inner NotNull annotations must be without the @ @NotNull.List( NotNull(name = "cardError", errorMessage = R.string.error_field_required), NotNull(name = "nameError", errorMessage = R.string.error_field_required), NotNull(name = "lastNameError", errorMessage = R.string.error_field_required) )
I am getting this error: Error:Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider com.wesleyelliott.kubwa.KubwaCompiler could not be instantiated: java.lang.NoClassDefFoundError: com/wesleyelliott/kubwa/rule/Rule
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.