]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
add rdata validate() method
authorBob Halley <halley@dnspython.org>
Wed, 18 Jan 2006 07:26:51 +0000 (07:26 +0000)
committerBob Halley <halley@dnspython.org>
Wed, 18 Jan 2006 07:26:51 +0000 (07:26 +0000)
ChangeLog
dns/rdata.py

index 70704975bb5163e0f374c33523972907cdc2cefb..d8b0aad9cb33d27371f7a22679171326ac7fac70 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-01-18  Bob Halley  <halley@dnspython.org>
+
+       * dns/rdata.py: added a validate() method to the rdata class.  If
+         you change an rdata by assigning to its fields, it is a good
+         idea to call validate() when you are done making changes.
+         For example, if 'r' is an MX record and then you execute:
+
+               r.preference = 100000   # invalid, because > 65535
+               r.validate()
+
+         The validation will fail and an exception will be raised.
+
 2006-01-11  Bob Halley  <halley@dnspython.org>
 
        * dns/ttl.py: TTLs are now bounds checked to be within the closed
index b7ac81ddb7625607ce634c8e4c76de6b1e7d34da..3ca3bfb21e4d619ebf6da486db398edb16360d2f 100644 (file)
@@ -169,6 +169,14 @@ class Rdata(object):
         """
         
         raise NotImplementedError
+
+    def validate(self):
+        """Check that the current contents of the rdata's fields are
+        valid.  If you change an rdata by assigning to its fields,
+        it is a good idea to call validate() when you are done making
+        changes.
+        """
+        dns.rdata.from_text(self.rdclass, self.rdtype, self.to_text())
         
     def __repr__(self):
        covers = self.covers()