예제 #1
0
    def is_length_less_than_or_equal_to(self, length):
        """Checks if the data provided is less than or equal to a specified length."""
        default_message = '{} is greater than {} characters'.format(
            self.display_name, str(length))

        if self.data and not CommonValidator.is_length_less_than_or_equal_to(
                self.data, length):
            self.validation_error_builder.add_error(self, default_message,
                                                    self.allow_multiple)

        return self
예제 #2
0
    def test_is_less_than_length_true_for_same_value(self):
        result = CommonValidator.is_length_less_than_or_equal_to(TEN_CHARS, 10)

        self.assertTrue(result)
예제 #3
0
    def test_is_less_than_length_false_for_long_value(self):
        result = CommonValidator.is_length_less_than_or_equal_to(
            ELEVEN_CHARS, 10)

        self.assertFalse(result)