Skip to content

Response Validations

mnipper edited this page Jan 27, 2014 · 2 revisions

A Question has a member variable that is a regular expression. You can test if a response matches the provided regular expression for its question by calling isValid() on a response object. If you would like to attempt to save a response, but only save if it matches the regular expression in its question, then call saveWithValidation().

The graphical piece of informing a user that a validation has failed is controlled in QuestionFragment via saveResponseWithValidation(). If you would like to save a response only if it matches the regular expression provided in its corresponding question, then call saveResponseWithValidation() in the question fragment. This will produce some graphical indication to the user that the response is not valid. If a regular expression message is provided, then it is displayed. Otherwise, a default message appears. If you do not care for validation for a particular type of question, you can just call save(), which will call ActiveAndroid's save.

Clone this wiki locally