questions.validators module

exception questions.validators.ValidationError[source]

Bases: Exception

Validation error exception, for use by Form.update_object.

questions.validators.call_validator(validator, value, form_data)[source]

Call correct validation method depending on validator type.

Parameters:
  • validator (Validator) – The validator instance for the current question.

  • value (Any) – The value to be validated.

  • form_data (Dict[str, Any]) – The dictionary containing from data entered for current form.

Returns:

If validation passes, True, else False.

questions.validators.email_validator(validator, value, form_data)[source]

Validate if value is a valid email address.

Parameters:
  • validator (Validator) – The validator instance for the current question.

  • value (Any) – The value to be validated.

  • form_data (Dict[str, Any]) – The dictionary containing from data entered for current form.

Returns:

If validation passes, True, else False.

questions.validators.expression_validator(validator, value, form_data)[source]

Validate if expression associated with value is true.

Parameters:
  • validator (Validator) – The validator instance for the current question.

  • value (Any) – The value to be validated.

  • form_data (Dict[str, Any]) – The dictionary containing from data entered for current form.

Returns:

If validation passes, True, else False.

questions.validators.numeric_validator(validator, value, form_data)[source]

Validate if number value is within set limits.

Parameters:
  • validator (Validator) – The validator instance for the current question.

  • value (Any) – The value to be validated.

  • form_data (Dict[str, Any]) – The dictionary containing from data entered for current form.

Returns:

If validation passes, True, else False.

questions.validators.regex_validator(validator, value, form_data)[source]

Validate if value matches regular expression.

Parameters:
  • validator (Validator) – The validator instance for the current question.

  • value (Any) – The value to be validated.

  • form_data (Dict[str, Any]) – The dictionary containing from data entered for current form.

Returns:

If validation passes, True, else False.

questions.validators.text_validator(validator, value, form_data)[source]

Validate length of a text value, and whether digits are allowed.

Parameters:
  • validator (Validator) – The validator instance for the current question.

  • value (Any) – The value to be validated.

  • form_data (Dict[str, Any]) – The dictionary containing from data entered for current form.

Returns:

If validation passes, True, else False.