1.2.1.4. validation

This module provides the functionality to perform context-sensitive validation of database models.

1.2.1.4.1. Functions

validate_credential(credential, campaign)[source]

Validate a credential object with regards to the configuration provided in campaign. This uses validate_credential_fields() to validate each field individually and then return either None, True or False. If no validation took place on any field, None is returned, otherwise if any field was validated then a boolean is returned indicating whether or not all validated (non-None) fields passed validation.

Parameters:
  • credential – The credential object to validate.
  • campaign – The campaign with the validation configuration.
Returns:

Either a boolean or None depending on the results.

validate_credential_fields(credential, campaign)[source]

Validate a credential object with regards to the configuration provided in campaign. Each field in the credential object is validated and a new CredentialCollection is returned with it’s fields set to the results of the validation. A fields validation results are either None, True or False. If no validation took place on the field, either because nothing was configured for it in campaign,or the validation information was invalid (a malformed regex for example) the result will be None. Otherwise, the result is either True or False for the field depending on the validation.

Parameters:
  • credential – The credential object to validate.
  • campaign – The campaign with the validation configuration.
Returns:

A CredentialCollection object with the fields set to the results of their respective validation.

Return type:

CredentialCollection

1.2.1.4.2. Classes

class CredentialCollection(username, password, mfa_token)[source]

Bases: tuple

A collection describing raw credential information.

mfa_token[source]

Alias for field number 2

password[source]

Alias for field number 1

username[source]

Alias for field number 0