tags:

views:

66

answers:

3
+1  Q: 

Java validators?

Hi, is there any Java validator libraries i can use to validate text input from an android app?

i know that in spring there are validators for various different types such as checking if a value is a int, if a value is a valid email, etc etc.

Anything similar in core java or even android?

cheers in advance. i dont want to re-invent the wheel if its already been implemented. i could always sue java reg expressions to construct my own ones but was wondering if their was one done specifically for email formats.

+1  A: 

You should write your own validator methods. E.g. you can use regex pattern for strings, java regex tutorial.

ArtWorkAD
+3  A: 

Normally I would suggest Hibernate Validator, but that is probably overkill for Android. If you're doing simple form input, you can write your own validation methods and use regular expressions to validate your input. There are a few regular expressions to validate emails addresses:

How to Find or Validate an Email Address

Vivin Paliath
+2  A: 

Hi,

I have written some supporting classes to fix this. It contains a validator interface, an abstract inplementation,a validationresult class and 2 examples of custom implemented validations. 1 for regular expressions on text and a simple one to check if a checkbox is checked.

Here is the link to my blog containing the sources and a small bit of explaining Form validation on Android: link text

Kind regards [http://nl.linkedin.com/in/marcdekwant]

Jaavaaan