From: Bob Halley Date: Wed, 18 Jan 2006 07:26:51 +0000 (+0000) Subject: add rdata validate() method X-Git-Tag: v1.4.0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c437c6badbabccb622a5f22aa4045fc9f41157a2;p=thirdparty%2Fdnspython.git add rdata validate() method --- diff --git a/ChangeLog b/ChangeLog index 70704975..d8b0aad9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-01-18 Bob Halley + + * 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 * dns/ttl.py: TTLs are now bounds checked to be within the closed diff --git a/dns/rdata.py b/dns/rdata.py index b7ac81dd..3ca3bfb2 100644 --- a/dns/rdata.py +++ b/dns/rdata.py @@ -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()