I have a method to validate that the fields are not empty, but now I need to validate that the user enters text with meaning or coherence, that is, not just writing, for example , smdfmasdmf :
public boolean validaData() {
boolean validate = false;
String propietario = edtPropietario.getText().toString().trim();
if (propietario.length()>5){
Log.i(TAG,"mayor a 5");
validate = true;
}
return validate;
}
With the above I ensure that you write 5 characters but they could be mjfgt without making sense
It is advisable to have a catalog where the words considered valid are defined.
You can use a file containing these words or consume an API that has this dictionary and that supports words in the Spanish language.
Check out: Top 10 Dictionary APIs You Should Be Using Right Now (English). You can also check the list of free APIs: https://rapidapi.com/collection/list-of-free-apis
An example similar to an API query would be using a .txt file containing the list of allowed words (stored in
res/raw/
):This would be the method to validate if the word is defined in the catalog:
Calling this method would determine if the word is valid: