Example #1
0
    def validate_configuration(
            self, configuration: Optional[ExpectationConfiguration]) -> None:
        super().validate_configuration(configuration)
        value = configuration["kwargs"].get("value")
        threshold = configuration["kwargs"].get("threshold")

        try:
            assert value is not None, "'value' must be specified"
            assert (
                isinstance(threshold, (int, float)) and 0 < threshold <= 1
            ) or (
                isinstance(threshold, list) and
                all(isinstance(x, (int, float)) for x in threshold)
                and
                all([0 < x <= 1 for x in threshold])
                and
                0
                <
                sum(threshold)
                <= 1
            ), "'threshold' must be 1, a float between 0 and 1, or a list of floats whose sum is between 0 and 1"
            if isinstance(threshold, list):
                assert isinstance(value, list) and len(value) == len(
                    threshold
                ), "'value' and 'threshold' must contain the same number of arguments"
        except AssertionError as e:
            raise InvalidExpectationConfigurationError(str(e))
Example #2
0
    def validate_configuration(
            self, configuration: Optional[ExpectationConfiguration]) -> None:
        super().validate_configuration(configuration)
        value = configuration["kwargs"].get("value")

        try:
            assert value is not None, "'value' must be specified"
            assert (
                isinstance(value, int) and value >= 0
            ), "`value` must be an integer greater than or equal to zero"
        except AssertionError as e:
            raise InvalidExpectationConfigurationError(str(e))
 def validate_configuration(
     self, configuration: Optional[ExpectationConfiguration]
 ) -> None:
     super().validate_configuration(configuration)
     if configuration is None:
         configuration = self.configuration
     try:
         assert (
             "column_A" in configuration.kwargs
             and "column_B" in configuration.kwargs
         ), "both columns must be provided"
     except AssertionError as e:
         raise InvalidExpectationConfigurationError(str(e))
 def validate_configuration(self, configuration: Optional[ExpectationConfiguration]):
     super().validate_configuration(configuration)
     try:
         assert (
             getattr(self, "regex", None) is not None
         ), "regex is required for RegexBasedColumnMap Expectations"
         assert (
             "column" in configuration.kwargs
         ), "'column' parameter is required for column map expectations"
         if "mostly" in configuration.kwargs:
             mostly = configuration.kwargs["mostly"]
             assert isinstance(
                 mostly, (int, float)
             ), "'mostly' parameter must be an integer or float"
             assert 0 <= mostly <= 1, "'mostly' parameter must be between 0 and 1"
     except AssertionError as e:
         raise InvalidExpectationConfigurationError(str(e))
     return True
Example #5
0
    def validate_configuration(
            self, configuration: Optional[ExpectationConfiguration]) -> None:
        """
        Validates that a configuration has been set, and sets a configuration if it has yet to be set. Ensures that
        necessary configuration arguments have been provided for the validation of the expectation.
        Args:
            configuration (OPTIONAL[ExpectationConfiguration]): \
                An optional Expectation Configuration entry that will be used to configure the expectation
        Returns:
            None. Raises InvalidExpectationConfigurationError if the config is not validated successfully
        """

        # Setting up a configuration
        super().validate_configuration(configuration)
        if configuration is None:
            configuration = self.configuration

        min_value = configuration.kwargs["min_value"]
        max_value = configuration.kwargs["max_value"]
        strict_min = configuration.kwargs["strict_min"]
        strict_max = configuration.kwargs["strict_max"]

        # Validating that min_val, max_val, strict_min, and strict_max are of the proper format and type
        try:
            assert (min_value is not None or max_value
                    is not None), "min_value and max_value cannot both be none"
            assert min_value is None or isinstance(
                min_value,
                (float, int)), "Provided min threshold must be a number"
            assert max_value is None or isinstance(
                max_value,
                (float, int)), "Provided max threshold must be a number"
            if min_value and max_value:
                assert (
                    min_value <= max_value
                ), "Provided min threshold must be less than or equal to max threshold"
            assert strict_min is None or isinstance(
                strict_min, bool), "strict_min must be a boolean value"
            assert strict_max is None or isinstance(
                strict_max, bool), "strict_max must be a boolean value"
        except AssertionError as e:
            raise InvalidExpectationConfigurationError(str(e))