diff options
author | Dr. Jens Harbott <harbott@osism.tech> | 2021-12-01 13:27:46 +0100 |
---|---|---|
committer | Michael Johnson <johnsomor@gmail.com> | 2022-06-02 04:09:39 +0000 |
commit | 4e6da9b9021466ddd2ee9eb9bcce2cf5a0d5fac7 (patch) | |
tree | fa5ad3f0762f7954413abf21510a4b1e94cbad97 | |
parent | e3d7854b07f080dbd0f35021034d83d98e79d21a (diff) | |
download | designate-4e6da9b9021466ddd2ee9eb9bcce2cf5a0d5fac7.tar.gz |
Improve wording for validation error messages
Correct some grammatical issues and harmonize the responses
Signed-off-by: Dr. Jens Harbott <harbott@osism.tech>
Change-Id: Ib45eae335160d53bb25e3745fcbe451bffa2cc31
(cherry picked from commit 296a5adaf95a221b985c026899662a611d936895)
-rw-r--r-- | designate/objects/fields.py | 29 | ||||
-rw-r--r-- | designate/tests/unit/objects/test_caa_object.py | 10 |
2 files changed, 20 insertions, 19 deletions
diff --git a/designate/objects/fields.py b/designate/objects/fields.py index dd3268c8..cda9efcc 100644 --- a/designate/objects/fields.py +++ b/designate/objects/fields.py @@ -206,9 +206,9 @@ class DomainField(StringFields): if len(host) > 63: raise ValueError("Host %s is too long" % host) if not value.endswith('.'): - raise ValueError("Domain %s is not end with a dot" % value) + raise ValueError("Domain %s does not end with a dot" % value) if not re.match(self.RE_ZONENAME, value): - raise ValueError("Domain %s is not match" % value) + raise ValueError("Domain %s is invalid" % value) return value @@ -222,7 +222,7 @@ class EmailField(StringFields): raise ValueError("%s is not an email" % value) email = value.replace('@', '.') if not re.match(self.RE_ZONENAME, "%s." % email): - raise ValueError("Email %s is not match" % value) + raise ValueError("Email %s is invalid" % value) return value @@ -239,9 +239,9 @@ class HostField(StringFields): if len(host) > 63: raise ValueError("Host %s is too long" % host) if value.endswith('.') is False: - raise ValueError("Host name %s is not end with a dot" % value) + raise ValueError("Host name %s does not end with a dot" % value) if not re.match(self.RE_HOSTNAME, value): - raise ValueError("Host name %s is not match" % value) + raise ValueError("Host name %s is invalid" % value) return value @@ -258,7 +258,7 @@ class SRVField(StringFields): if len(host) > 63: raise ValueError("Host %s is too long" % host) if value.endswith('.') is False: - raise ValueError("Host name %s is not end with a dot" % value) + raise ValueError("Host name %s does not end with a dot" % value) if not re.match(self.RE_SRV_HOST_NAME, value): raise ValueError("Host name %s is not a SRV record" % value) return value @@ -293,7 +293,7 @@ class TldField(StringFields): def coerce(self, obj, attr, value): value = super(TldField, self).coerce(obj, attr, value) if not re.match(self.RE_TLDNAME, value): - raise ValueError("%s is not an TLD" % value) + raise ValueError("%s is not a TLD" % value) return value @@ -321,7 +321,7 @@ class NaptrServiceField(StringFields): raise ValueError("NAPTR record service field cannot be longer than" " 255 characters" % value) if not re.match(self.RE_NAPTR_SERVICE, "%s" % value): - raise ValueError("%s NAPTR record service does not match" % value) + raise ValueError("%s NAPTR record service is invalid" % value) return value @@ -336,7 +336,7 @@ class NaptrRegexpField(StringFields): " 255 characters" % value) if value: if not re.match(self.RE_NAPTR_REGEXP, "%s" % value): - raise ValueError("%s is not a NAPTR record regexp" % value) + raise ValueError("%s NAPTR record is invalid" % value) return value @@ -358,10 +358,11 @@ class CaaPropertyField(StringFields): raise ValueError("Host %s is too long" % host) idn_with_dot = idn + '.' if not re.match(self.RE_ZONENAME, idn_with_dot): - raise ValueError("Domain %s does not match" % idn) + raise ValueError("Domain %s is invalid" % idn) for entry in entries: if not re.match(self.RE_KVP, entry): - raise ValueError("%s is not valid key-value pair" % entry) + raise ValueError("%s is not a valid key-value pair" % + entry) elif tag == 'iodef': if re.match(self.RE_URL_MAIL, val): parts = val.split('@') @@ -372,7 +373,7 @@ class CaaPropertyField(StringFields): raise ValueError("Host %s is too long" % host) idn_with_dot = idn + '.' if not re.match(self.RE_ZONENAME, idn_with_dot): - raise ValueError("Domain %s does not match" % idn) + raise ValueError("Domain %s is invalid" % idn) elif re.match(self.RE_URL_HTTP, val): parts = val.split('/') idn = parts[2] @@ -382,9 +383,9 @@ class CaaPropertyField(StringFields): raise ValueError("Host %s is too long" % host) idn_with_dot = idn + '.' if not re.match(self.RE_ZONENAME, idn_with_dot): - raise ValueError("Domain %s does not match" % idn) + raise ValueError("Domain %s is invalid" % idn) else: - raise ValueError("%s is not valid URL" % val) + raise ValueError("%s is not a valid URL" % val) else: raise ValueError("Property tag %s must be 'issue', 'issuewild'" " or 'iodef'" % value) diff --git a/designate/tests/unit/objects/test_caa_object.py b/designate/tests/unit/objects/test_caa_object.py index 877ffb25..023944bf 100644 --- a/designate/tests/unit/objects/test_caa_object.py +++ b/designate/tests/unit/objects/test_caa_object.py @@ -72,7 +72,7 @@ class CAARecordTest(oslotest.base.BaseTestCase): caa_record = objects.CAA() self.assertRaisesRegex( ValueError, - 'Domain abc. does not match', + 'Domain abc. is invalid', caa_record._from_string, '0 issue abc.' ) @@ -80,7 +80,7 @@ class CAARecordTest(oslotest.base.BaseTestCase): caa_record = objects.CAA() self.assertRaisesRegex( ValueError, - 'def is not valid key-value pair', + 'def is not a valid key-value pair', caa_record._from_string, '0 issue abc;def' ) @@ -98,7 +98,7 @@ class CAARecordTest(oslotest.base.BaseTestCase): caa_record = objects.CAA() self.assertRaisesRegex( ValueError, - 'Domain example.net. does not match', + 'Domain example.net. is invalid', caa_record._from_string, '0 iodef mailto:me@example.net.' ) @@ -116,7 +116,7 @@ class CAARecordTest(oslotest.base.BaseTestCase): caa_record = objects.CAA() self.assertRaisesRegex( ValueError, - 'Domain example.net. does not match', + 'Domain example.net. is invalid', caa_record._from_string, '0 iodef https://example.net./' ) @@ -124,6 +124,6 @@ class CAARecordTest(oslotest.base.BaseTestCase): caa_record = objects.CAA() self.assertRaisesRegex( ValueError, - 'https:// is not valid URL', + 'https:// is not a valid URL', caa_record._from_string, '0 iodef https://' ) |