Available validators

pycerberus contains some basic validators already. You can use them as they are or use them as a basis for more specialized validators. Below you find a list of all included validators.

class pycerberus.validators.basic_numbers.IntegerValidator(self, min=None, max=None, *args, **kwargs)

Bases: pycerberus.api.Validator

convert(value, context)
keys()

Return all keys defined by this specific validator class.

message_for_key(key, context)

Return a message for a specific key. Implement this method if you want to avoid calls to messages() which might be costly (otherwise implementing this method is optional).

messages()
validate(value, context)
class pycerberus.validators.domain.DomainNameValidator(self, default=NoValueSet, required=NoValueSet, strip=False)

Bases: pycerberus.validators.string.StringValidator

A validator to check if an domain name is syntactically correct.

keys()

Return all keys defined by this specific validator class.

message_for_key(key, context)

Return a message for a specific key. Implement this method if you want to avoid calls to messages() which might be costly (otherwise implementing this method is optional).

class pycerberus.validators.email.EmailAddressValidator(self, default=NoValueSet, required=NoValueSet, strip=False)

Bases: pycerberus.validators.domain.DomainNameValidator

A validator to check if an email address is syntactically correct.

Please note that there is no clear definition of an ‘email address’. Some parts are defined in consecutive RFCs, there is a notion of ‘string that is accepted by a MTA’ and last but not least a fuzzy ‘general expectation’ what an email address should be about.

Therefore this validator is currently extremly simple and does not handle internationalized local parts/domains.

For the future I envision some extensions here:
  • support internationalized domain names (possibly also encode to/ decode from idna) if specified by flag
  • More flexible structure if there must be a second-level domain
Something that should not happen in this validator:
  • Open SMTP connections to check if an account exists
  • specify default domains if missing

These things can be implemented in derived validators

keys()

Return all keys defined by this specific validator class.

message_for_key(key, context)

Return a message for a specific key. Implement this method if you want to avoid calls to messages() which might be costly (otherwise implementing this method is optional).

class pycerberus.validators.string.StringValidator(self, default=NoValueSet, required=NoValueSet, strip=False)

Bases: pycerberus.api.Validator

convert(value, context)
is_empty(value, context)
keys()

Return all keys defined by this specific validator class.

message_for_key(key, context)

Return a message for a specific key. Implement this method if you want to avoid calls to messages() which might be costly (otherwise implementing this method is optional).

messages()

Previous topic

pycerberus documentation

This Page