file: allow for missing file header and control
@@ -591,6 +591,12 @@ type ValidateOpts struct {
// AllowZeroBatches allows the file to have zero batches
AllowZeroBatches bool `json:"allowZeroBatches"`
+ // AllowMissingFileHeader
+ AllowMissingFileHeader bool `json:"allowMissingFileHeader"`
+
+ // AllowMissingFileControl
+ AllowMissingFileControl bool `json:"allowMissingFileControl"`
+
// BypassCompanyIdentificationMatch allows batches in which the Company Identification field
// in the batch header and control do not match.
BypassCompanyIdentificationMatch bool `json:"bypassCompanyIdentificationMatch"`
@@ -617,9 +623,11 @@ func (f *File) ValidateWith(opts *ValidateOpts) error {
opts = &ValidateOpts{}
}
+ if !opts.AllowMissingFileHeader {
if err := f.Header.ValidateWith(opts); err != nil {
return err
}
+ }
if !f.IsADV() {
// The value of the Batch Count Field is equal to the number of Company/Batch/Header Records in the file.
@@ -633,9 +641,11 @@ func (f *File) ValidateWith(opts *ValidateOpts) error {
}
}
+ if !opts.AllowMissingFileControl {
if err := f.Control.Validate(); err != nil {
return err
}
+ }
if err := f.isEntryAddendaCount(false); err != nil {
return err
}
@@ -654,9 +664,11 @@ func (f *File) ValidateWith(opts *ValidateOpts) error {
if f.ADVControl.BatchCount != len(f.Batches) {
return NewErrFileCalculatedControlEquality("BatchCount", len(f.Batches), f.ADVControl.BatchCount)
}
+ if !opts.AllowMissingFileControl {
if err := f.ADVControl.Validate(); err != nil {
return err
}
+ }
if err := f.isEntryAddendaCount(true); err != nil {
return err
}
