Skip to content

Commit

Permalink
added validation check to entry fields zipline/nACH glenselle#9
Browse files Browse the repository at this point in the history
  • Loading branch information
yawetse committed Mar 6, 2015
1 parent aa06587 commit 0fec7f2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/entry/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// Entry

'use strict';
var _ = require('lodash');
var utils = require('./../utils');
var validate = require('./../validate');

var highLevelOverrides = ['transactionCode','receivingDFI','checkDigit','DFIAccount','amount','idNumber','individualName','discretionaryData','addendaId','traceNumber'];

function Entry(options) {

// Allow the file header defaults to be overriden if provided
this.fields = options.fields ? _.merge(options.fields, require('./fields'), _.defaults) : _.cloneDeep(require('./fields'));

Expand All @@ -16,8 +15,8 @@ function Entry(options) {

// Some values need special coercing, so after they've been set by overrideLowLevel() we override them
if(options.receivingDFI) {
this.fields.receivingDFI.value = options.receivingDFI.slice(0,-1);
this.fields.checkDigit.value = options.receivingDFI.slice(-1);
this.fields.receivingDFI.value = (this.fields.receivingDFI.value.length>8)? options.receivingDFI.slice(0,-1) : this.fields.receivingDFI.value ;
this.fields.checkDigit.value = (!options.checkDigit && this.fields.receivingDFI.value.length>8)? options.receivingDFI.slice(-1): this.fields.checkDigit.value;
}

if(options.DFIAccount) {
Expand Down

0 comments on commit 0fec7f2

Please sign in to comment.