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

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

        return self
예제 #2
0
    def test_is_length_equal_to_false(self):
        result = CommonValidator.is_length_equal_to(NINE_CHARS, 10)

        self.assertFalse(result)
예제 #3
0
    def test_is_length_equal_to_true(self):
        result = CommonValidator.is_length_equal_to(NINE_CHARS, 9)

        self.assertTrue(result)