Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cleancat/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def clean(self, value):
allowed_types_text = " or ".join(allowed_types)
else:
allowed_types_text = self.base_type.__name__
err_msg = "Value must be of %s type." % allowed_types_text
err_msg = "The value must be of %s type." % allowed_types_text
raise ValidationError(err_msg)

if not self.has_value(value):
Expand Down Expand Up @@ -622,7 +622,7 @@ def clean(self, value):
choices = {choice.lower(): choice for choice in choices}

if not isinstance(value, str):
raise ValidationError("Value needs to be a string.")
raise ValidationError("The value needs to be a string.")

if value.lower() not in choices:
err_msg = self.format_invalid_choice_msg(value)
Expand Down Expand Up @@ -847,7 +847,7 @@ def full_clean(self): # noqa: C901
)

if value != old_value:
raise ValidationError("Value cannot be changed.")
raise ValidationError("The value cannot be changed.")

self.data[field_name] = value

Expand Down
30 changes: 15 additions & 15 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class IntOrStrField(Field):
assert IntOrStrField().clean(5) == 5
assert IntOrStrField().clean("five") == "five"

expected_err_msg = "Value must be of int or str type."
expected_err_msg = "The value must be of int or str type."
with pytest.raises(ValidationError, match=expected_err_msg):
assert IntOrStrField().clean(4.5)

Expand Down Expand Up @@ -77,7 +77,7 @@ def test_it_falls_back_to_the_default_value(self, value):
assert e.value.args[0] == "default"

def test_it_enforces_valid_data_type(self):
expected_err_msg = "Value must be of str type."
expected_err_msg = "The value must be of str type."
with pytest.raises(ValidationError, match=expected_err_msg):
String().clean(True)

Expand Down Expand Up @@ -156,7 +156,7 @@ def test_it_can_be_optional(self, value):
assert e.value.args[0] == ""

def test_it_enforces_valid_data_type(self):
expected_err_msg = "Value must be of str type."
expected_err_msg = "The value must be of str type."
with pytest.raises(ValidationError, match=expected_err_msg):
TrimmedString().clean(True)

Expand Down Expand Up @@ -209,7 +209,7 @@ def test_it_enforces_required_flag(self):
Bool().clean(None)

def test_it_enforces_valid_data_type(self):
expected_err_msg = "Value must be of bool type."
expected_err_msg = "The value must be of bool type."
with pytest.raises(ValidationError, match=expected_err_msg):
Bool().clean("")

Expand Down Expand Up @@ -253,7 +253,7 @@ def test_it_can_be_optional(self, value):
assert e.value.args[0] == ""

def test_it_enforces_valid_data_type(self):
expected_err_msg = "Value must be of str type."
expected_err_msg = "The value must be of str type."
with pytest.raises(ValidationError, match=expected_err_msg):
Regex("^[a-z]$").clean(True)

Expand Down Expand Up @@ -304,7 +304,7 @@ def test_it_can_be_optional(self, value):
assert e.value.args[0] is None

def test_it_enforces_valid_data_type(self):
expected_err_msg = "Value must be of str type."
expected_err_msg = "The value must be of str type."
with pytest.raises(ValidationError, match=expected_err_msg):
DateTime().clean(True)

Expand Down Expand Up @@ -369,7 +369,7 @@ def test_it_can_be_optional(self, value):
assert e.value.args[0] == ""

def test_it_enforces_valid_data_type(self):
expected_err_msg = "Value must be of str type."
expected_err_msg = "The value must be of str type."
with pytest.raises(ValidationError, match=expected_err_msg):
Email().clean(True)

Expand Down Expand Up @@ -431,7 +431,7 @@ def test_it_can_be_optional(self):

@pytest.mark.parametrize("value", ["", "0", 23.0])
def test_it_enforces_valid_data_type(self, value):
expected_err_msg = "Value must be of int type."
expected_err_msg = "The value must be of int type."
with pytest.raises(ValidationError, match=expected_err_msg):
Integer().clean(value)

Expand All @@ -445,8 +445,8 @@ def test_it_validates_each_value(self):
with pytest.raises(ValidationError) as e:
List(String(max_length=3)).clean(["a", 2, "c", "long"])
assert e.value.args[0]["errors"][1] in (
"Value must be of basestring type.",
"Value must be of str type.",
"The value must be of basestring type.",
"The value must be of str type.",
)
assert e.value.args[0]["errors"][3] == (
"The value must be no longer than 3 characters."
Expand Down Expand Up @@ -540,7 +540,7 @@ def test_it_can_be_optional(self):

@pytest.mark.parametrize("value", [23.0, True])
def test_it_enforces_valid_data_type(self, value):
expected_err_msg = "Value must be of list type."
expected_err_msg = "The value must be of list type."
with pytest.raises(ValidationError, match=expected_err_msg):
SortedSet(String()).clean(value)

Expand Down Expand Up @@ -708,7 +708,7 @@ def test_it_can_be_optional(self, value):

@pytest.mark.parametrize("value", [23.0, True])
def test_it_enforces_valid_data_type(self, value):
expected_err_msg = "Value must be of str type."
expected_err_msg = "The value must be of str type."
with pytest.raises(ValidationError, match=expected_err_msg):
URL().clean(value)

Expand Down Expand Up @@ -749,7 +749,7 @@ def test_it_accepts_scheme_only_urls_if_not_required(

@pytest.mark.parametrize("value", [23.0, True])
def test_it_enforces_valid_data_type(self, value):
expected_err_msg = "Value must be of str type."
expected_err_msg = "The value must be of str type."
with pytest.raises(ValidationError, match=expected_err_msg):
RelaxedURL().clean(value)

Expand Down Expand Up @@ -911,7 +911,7 @@ class UnmutableSchema(Schema):
schema.full_clean()
assert e.value.args[0] == {
"errors": [],
"field-errors": {"text": "Value cannot be changed."},
"field-errors": {"text": "The value cannot be changed."},
}

def test_serialization(self):
Expand Down Expand Up @@ -1041,7 +1041,7 @@ class TestSchema(Schema):
schema.full_clean()

assert schema.field_errors == {
"value_id": "Value must be of int type."
"value_id": "The value must be of int type."
}


Expand Down