great_expectations.marshmallow__shade.validate
¶
Validation classes for various types of data.
Module Contents¶
Classes¶
Base abstract class for validators. |
|
|
Validate a URL. |
|
Validate an email address. |
|
Validator which succeeds if the value passed to it is within the specified |
|
Validator which succeeds if the value passed to it has a |
|
Validator which succeeds if the |
|
Validator which succeeds if the |
|
Call the specified |
|
Validator which fails if |
|
Validator which succeeds if |
|
Validator which succeeds if |
|
Validator which fails if |
-
class
great_expectations.marshmallow__shade.validate.
Validator
¶ Base abstract class for validators.
Note
This class does not provide any behavior. It is only used to add a useful __repr__ implementation for validators.
-
error
:typing.Optional[str]¶
-
__repr__
(self)¶ Return repr(self).
-
_repr_args
(self)¶ A string representation of the args passed to this validator. Used by __repr__.
-
-
class
great_expectations.marshmallow__shade.validate.
URL
(*, relative: bool = False, schemes: types.StrSequenceOrSet = None, require_tld: bool = True, error: str = None)¶ Bases:
great_expectations.marshmallow__shade.validate.Validator
Validate a URL.
- Parameters
relative – Whether to allow relative URLs.
error – Error message to raise in case of a validation error. Can be interpolated with {input}.
schemes – Valid schemes. By default,
http
,https
,ftp
, andftps
are allowed.require_tld – Whether to reject non-FQDN hostnames.
-
class
RegexMemoizer
¶ -
_regex_generator
(self, relative: bool, require_tld: bool)¶
-
__call__
(self, relative: bool, require_tld: bool)¶
-
-
_regex
¶
-
default_message
= Not a valid URL.¶
-
default_schemes
¶
-
_repr_args
(self)¶ A string representation of the args passed to this validator. Used by __repr__.
-
_format_error
(self, value)¶
-
__call__
(self, value)¶
-
class
great_expectations.marshmallow__shade.validate.
Email
(*, error: str = None)¶ Bases:
great_expectations.marshmallow__shade.validate.Validator
Validate an email address.
- Parameters
error – Error message to raise in case of a validation error. Can be interpolated with {input}.
-
USER_REGEX
¶
-
DOMAIN_REGEX
¶
-
DOMAIN_WHITELIST
= ['localhost']¶
-
default_message
= Not a valid email address.¶
-
_format_error
(self, value)¶
-
__call__
(self, value)¶
-
class
great_expectations.marshmallow__shade.validate.
Range
(min=None, max=None, *, min_inclusive: bool = True, max_inclusive: bool = True, error: str = None)¶ Bases:
great_expectations.marshmallow__shade.validate.Validator
Validator which succeeds if the value passed to it is within the specified range. If
min
is not specified, or is specified as None, no lower bound exists. Ifmax
is not specified, or is specified as None, no upper bound exists. The inclusivity of the bounds (if they exist) is configurable. Ifmin_inclusive
is not specified, or is specified as True, then themin
bound is included in the range. Ifmax_inclusive
is not specified, or is specified as True, then themax
bound is included in the range.- Parameters
min – The minimum value (lower bound). If not provided, minimum value will not be checked.
max – The maximum value (upper bound). If not provided, maximum value will not be checked.
min_inclusive – Whether the min bound is included in the range.
max_inclusive – Whether the max bound is included in the range.
error – Error message to raise in case of a validation error. Can be interpolated with {input}, {min} and {max}.
-
message_min
= Must be {min_op} {{min}}.¶
-
message_max
= Must be {max_op} {{max}}.¶
-
message_all
= Must be {min_op} {{min}} and {max_op} {{max}}.¶
-
message_gte
= greater than or equal to¶
-
message_gt
= greater than¶
-
message_lte
= less than or equal to¶
-
message_lt
= less than¶
-
_repr_args
(self)¶ A string representation of the args passed to this validator. Used by __repr__.
-
_format_error
(self, value, message: str)¶
-
__call__
(self, value)¶
-
class
great_expectations.marshmallow__shade.validate.
Length
(min: int = None, max: int = None, *, equal: int = None, error: str = None)¶ Bases:
great_expectations.marshmallow__shade.validate.Validator
Validator which succeeds if the value passed to it has a length between a minimum and maximum. Uses len(), so it can work for strings, lists, or anything with length.
- Parameters
min – The minimum length. If not provided, minimum length will not be checked.
max – The maximum length. If not provided, maximum length will not be checked.
equal – The exact length. If provided, maximum and minimum length will not be checked.
error – Error message to raise in case of a validation error. Can be interpolated with {input}, {min} and {max}.
-
message_min
= Shorter than minimum length {min}.¶
-
message_max
= Longer than maximum length {max}.¶
-
message_all
= Length must be between {min} and {max}.¶
-
message_equal
= Length must be {equal}.¶
-
_repr_args
(self)¶ A string representation of the args passed to this validator. Used by __repr__.
-
_format_error
(self, value, message: str)¶
-
__call__
(self, value)¶
-
class
great_expectations.marshmallow__shade.validate.
Equal
(comparable, *, error: str = None)¶ Bases:
great_expectations.marshmallow__shade.validate.Validator
Validator which succeeds if the
value
passed to it is equal tocomparable
.- Parameters
comparable – The object to compare to.
error – Error message to raise in case of a validation error. Can be interpolated with {input} and {other}.
-
default_message
= Must be equal to {other}.¶
-
_repr_args
(self)¶ A string representation of the args passed to this validator. Used by __repr__.
-
_format_error
(self, value)¶
-
__call__
(self, value)¶
-
class
great_expectations.marshmallow__shade.validate.
Regexp
(regex: typing.Union[str, bytes, typing.Pattern], flags=0, *, error: str = None)¶ Bases:
great_expectations.marshmallow__shade.validate.Validator
Validator which succeeds if the
value
matchesregex
.Note
Uses re.match, which searches for a match at the beginning of a string.
- Parameters
regex – The regular expression string to use. Can also be a compiled regular expression pattern.
flags – The regexp flags to use, for example re.IGNORECASE. Ignored if
regex
is not a string.error – Error message to raise in case of a validation error. Can be interpolated with {input} and {regex}.
-
default_message
= String does not match expected pattern.¶
-
_repr_args
(self)¶ A string representation of the args passed to this validator. Used by __repr__.
-
_format_error
(self, value)¶
-
__call__
(self, value)¶
-
class
great_expectations.marshmallow__shade.validate.
Predicate
(method: str, *, error: str = None, **kwargs)¶ Bases:
great_expectations.marshmallow__shade.validate.Validator
Call the specified
method
of thevalue
object. The validator succeeds if the invoked method returns an object that evaluates to True in a Boolean context. Any additional keyword argument will be passed to the method.- Parameters
method – The name of the method to invoke.
error – Error message to raise in case of a validation error. Can be interpolated with {input} and {method}.
kwargs – Additional keyword arguments to pass to the method.
-
default_message
= Invalid input.¶
-
_repr_args
(self)¶ A string representation of the args passed to this validator. Used by __repr__.
-
_format_error
(self, value)¶
-
__call__
(self, value)¶
-
class
great_expectations.marshmallow__shade.validate.
NoneOf
(iterable: typing.Iterable, *, error: str = None)¶ Bases:
great_expectations.marshmallow__shade.validate.Validator
Validator which fails if
value
is a member ofiterable
.- Parameters
iterable – A sequence of invalid values.
error – Error message to raise in case of a validation error. Can be interpolated using {input} and {values}.
-
default_message
= Invalid input.¶
-
_repr_args
(self)¶ A string representation of the args passed to this validator. Used by __repr__.
-
_format_error
(self, value)¶
-
__call__
(self, value)¶
-
class
great_expectations.marshmallow__shade.validate.
OneOf
(choices: typing.Iterable, labels: typing.Iterable[str] = None, *, error: str = None)¶ Bases:
great_expectations.marshmallow__shade.validate.Validator
Validator which succeeds if
value
is a member ofchoices
.- Parameters
choices – A sequence of valid values.
labels – Optional sequence of labels to pair with the choices.
error – Error message to raise in case of a validation error. Can be interpolated with {input}, {choices} and {labels}.
-
default_message
= Must be one of: {choices}.¶
-
_repr_args
(self)¶ A string representation of the args passed to this validator. Used by __repr__.
-
_format_error
(self, value)¶
-
__call__
(self, value)¶
-
options
(self, valuegetter: typing.Union[str, typing.Callable[[typing.Any], typing.Any]] = str)¶ Return a generator over the (value, label) pairs, where value is a string associated with each choice. This convenience method is useful to populate, for instance, a form select field.
- Parameters
valuegetter – Can be a callable or a string. In the former case, it must be a one-argument callable which returns the value of a choice. In the latter case, the string specifies the name of an attribute of the choice objects. Defaults to str() or str().
-
class
great_expectations.marshmallow__shade.validate.
ContainsOnly
(choices: typing.Iterable, labels: typing.Iterable[str] = None, *, error: str = None)¶ Bases:
great_expectations.marshmallow__shade.validate.OneOf
Validator which succeeds if
value
is a sequence and each element in the sequence is also in the sequence passed aschoices
. Empty input is considered valid.- Parameters
Changed in version 3.0.0b2: Duplicate values are considered valid.
Changed in version 3.0.0b2: Empty input is considered valid. Use validate.Length(min=1) <marshmallow.validate.Length> to validate against empty inputs.
-
default_message
= One or more of the choices you made was not in: {choices}.¶
-
_format_error
(self, value)¶
-
__call__
(self, value)¶
-
class
great_expectations.marshmallow__shade.validate.
ContainsNoneOf
(iterable: typing.Iterable, *, error: str = None)¶ Bases:
great_expectations.marshmallow__shade.validate.NoneOf
Validator which fails if
value
is a sequence and any element in the sequence is a member of the sequence passed asiterable
. Empty input is considered valid.-
default_message
= One or more of the choices you made was in: {values}.¶
-
_format_error
(self, value)¶
-
__call__
(self, value)¶
-