tweaking validation
This commit is contained in:
parent
afc4138898
commit
d058e64d26
1 changed files with 5 additions and 3 deletions
|
@ -6,6 +6,7 @@ import pdb
|
|||
class Model(object):
|
||||
record_identifier = ' '
|
||||
required = False
|
||||
record_length = 512
|
||||
|
||||
def __init__(self):
|
||||
for (key, value) in self.__class__.__dict__.items():
|
||||
|
@ -52,9 +53,10 @@ class Model(object):
|
|||
custom_validator(f)
|
||||
|
||||
def output(self):
|
||||
result = ''.join([self.record_identifier] + [field.get_data() for field in self.get_sorted_fields()])
|
||||
if len(result) != 512:
|
||||
raise ValidationError("Record result length not equal to 512 bytes (%d)" % len(result))
|
||||
result = ''.join([self.record_identifier] +
|
||||
[field.get_data() for field in self.get_sorted_fields()])
|
||||
if len(result) != self.record_length:
|
||||
raise ValidationError("Record result length not equal to %d bytes (%d)" % (self.record_length, len(result)))
|
||||
return result
|
||||
|
||||
def read(self, fp):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue