From f30237a90d84ab8bd1d8940710957862b3dfbde3 Mon Sep 17 00:00:00 2001 From: Binh Van Nguyen Date: Sat, 23 Apr 2011 14:57:18 -0500 Subject: [PATCH] added custom field-record validator support, not using it yet though --- model.py | 7 +++++++ record.py | 1 + 2 files changed, 8 insertions(+) diff --git a/model.py b/model.py index 27686dc..731a088 100644 --- a/model.py +++ b/model.py @@ -33,6 +33,13 @@ class Model(object): for f in self.get_fields(): f.validate() + try: + custom_validator = getattr(self, 'validate_' + f.name) + except AttributeError, e: + continue + if callable(custom_validator): + custom_validator(f) + def output(self): return ''.join([self.record_identifier] + [field.get_data() for field in self.get_sorted_fields()]) diff --git a/record.py b/record.py index d9e617d..5efcdf3 100644 --- a/record.py +++ b/record.py @@ -75,6 +75,7 @@ class EmployerRecord(model.Model): third_party_sick_pay = BooleanField() blank2 = BlankField(max_length=291) + class EmployeeWageRecord(model.Model): record_identifier = 'RW'