ragunathjawahar / android-saripaar

UI form validation library for Android
Apache License 2.0
3.22k stars 460 forks source link

Email rule is missing some constraints #222

Open alihabbash opened 5 years ago

alihabbash commented 5 years ago

I have applied the email annotation to a TextInputlayout after register a ViewDataAdapter but the email validator is accepting emails with scheme like some@exa (Without the .com .org ...etc).

nstdio commented 5 years ago

@alihabbash same is here. I'm using version 2.0.3, also @Email does accept inputs like test@.com.

nstdio commented 5 years ago

As a workaround we could use @Pattern

public static final String EMAIL_ADDRESS_PATTERN = "[a-zA-Z0-9\\+\\.\\_\\%\\-\\+]{1,256}\\@[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25})+";

@Pattern(regex = EMAIL_ADDRESS_PATTERN)
TextInputEditText email;

The email address pattern was take from here.