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):
|
class Model(object):
|
||||||
record_identifier = ' '
|
record_identifier = ' '
|
||||||
required = False
|
required = False
|
||||||
|
record_length = 512
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
for (key, value) in self.__class__.__dict__.items():
|
for (key, value) in self.__class__.__dict__.items():
|
||||||
|
@ -52,9 +53,10 @@ class Model(object):
|
||||||
custom_validator(f)
|
custom_validator(f)
|
||||||
|
|
||||||
def output(self):
|
def output(self):
|
||||||
result = ''.join([self.record_identifier] + [field.get_data() for field in self.get_sorted_fields()])
|
result = ''.join([self.record_identifier] +
|
||||||
if len(result) != 512:
|
[field.get_data() for field in self.get_sorted_fields()])
|
||||||
raise ValidationError("Record result length not equal to 512 bytes (%d)" % len(result))
|
if len(result) != self.record_length:
|
||||||
|
raise ValidationError("Record result length not equal to %d bytes (%d)" % (self.record_length, len(result)))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def read(self, fp):
|
def read(self, fp):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue