vekexasia / android-edittext-validator

Android form edit text is an extension of EditText that brings data validation facilities to the edittext.
MIT License
1.45k stars 378 forks source link

How to.....Exclude certain words? #31

Closed sirvon closed 9 years ago

sirvon commented 9 years ago

I know I'm cheating but hey #YOLO...

thanks for the lib btw!

So, If I want to exclude certain words from being entered/accepted in the edittext, what shall i do?

for example, if a app member types, vase, I want to tell them sorry but that word can't be submitted.

Thanks!!

vekexasia commented 9 years ago

You want to allow everything but some words?

sirvon commented 9 years ago

Correct. On Nov 19, 2014 2:39 AM, "Andrea Baccega" notifications@github.com wrote:

You want to allow everything but some words?

— Reply to this email directly or view it on GitHub https://github.com/vekexasia/android-edittext-validator/issues/31#issuecomment-63621071 .

vekexasia commented 9 years ago

What about using something like

FormEditText myEditText = (FormEditText) findViewById(R.id.my_edittext);
Validator validator = new NotValidator("You cannot use these words", new  RegexpValidator(null, "(banana|apple)"));

myEditText.addValidator(validator);

This will pass for everything not containing the words banana or apple :)

sirvon commented 9 years ago

thanks for the example, will try. ill tell you how it goes.

sirvon commented 9 years ago

it worked. thank you! personal tutorials on ones code is so priceless in implementation and understanding! thank you once again!