Exemplo n.º 1
0
    def test_min_rule_with_invalid_decimal_expect_error(self):
        rules = {"test": "min:0.5"}
        data = {"test": Decimal("0.4")}
        expected = MIN_ERROR.format(field=self.field, min=0.5)

        errors = self.validator.validate(data, rules)
        errs = errors.get(self.field)

        self.assertEqual(errs[0], expected)
Exemplo n.º 2
0
    def test_min_rule_with_int_value_and_float_rule_expect_error(self):
        rules = {"test": "min:1.1"}
        data = {"test": 1}
        expected = MIN_ERROR.format(field=self.field, min=1.1)

        errors = self.validator.validate(data, rules)
        errs = errors.get(self.field)

        self.assertEqual(errs[0], expected)
Exemplo n.º 3
0
    def test_min_rule_with_invalid_integer_expect_error(self):
        rules = {"test": "min:5"}
        data = {"test": 4}
        expected = MIN_ERROR.format(field=self.field, min=5)

        errors = self.validator.validate(data, rules)
        errs = errors.get(self.field)

        self.assertEqual(errs[0], expected)