Skip to content

Commit

Permalink
Do not throw IncorrectDataFormat exception if value is empty and Vali…
Browse files Browse the repository at this point in the history
…dateFieldsHaveValues=N (#207)

* do not throw IncorrectDataFormat exception if value is empty and ValidateFieldsHaveValues=N
  • Loading branch information
jonfreedman authored and chrjohn committed Aug 2, 2018
1 parent 23aa52c commit c790dac
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions quickfixj-core/src/main/java/quickfix/DataDictionary.java
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,9 @@ private void checkValidFormat(StringField field) throws IncorrectDataFormat {
if (fieldType == null) {
return;
}
if (!checkFieldsHaveValues && field.getValue().length() == 0) {
return;
}
try {
switch (fieldType) {
case STRING:
Expand Down
24 changes: 24 additions & 0 deletions quickfixj-core/src/test/java/quickfix/DataDictionaryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import quickfix.field.BodyLength;
import quickfix.field.CheckSum;
import quickfix.field.ClOrdID;
import quickfix.field.EffectiveTime;
import quickfix.field.HandlInst;
import quickfix.field.LastMkt;
import quickfix.field.MsgSeqNum;
Expand Down Expand Up @@ -1275,6 +1276,29 @@ public void testGroupWithReqdComponentWithReqdFieldValidation() throws Exception
dictionary.validate(quoteRequest, true);
}

/**
* Field EffectiveTime(168) is defined as UTCTIMESTAMP so an empty string value is invalid but if we allow blank values that should not fail
* validation
* @throws Exception
*/
@Test
public void testAllowingBlankValuesDisablesFieldValidation() throws Exception {
final DataDictionary dictionary = getDictionary();
dictionary.setCheckFieldsHaveValues(false);
final quickfix.fix44.NewOrderSingle newSingle = new quickfix.fix44.NewOrderSingle(
new ClOrdID("123"), new Side(Side.BUY), new TransactTime(), new OrdType(OrdType.LIMIT)
);
newSingle.setField(new OrderQty(42));
newSingle.setField(new Price(42.37));
newSingle.setField(new HandlInst());
newSingle.setField(new Symbol("QFJ"));
newSingle.setField(new HandlInst(HandlInst.MANUAL_ORDER_BEST_EXECUTION));
newSingle.setField(new TimeInForce(TimeInForce.DAY));
newSingle.setField(new Account("testAccount"));
newSingle.setField(new StringField(EffectiveTime.FIELD));
dictionary.validate(newSingle, true);
}

//
// Group Validation Tests in RepeatingGroupTest
//
Expand Down

0 comments on commit c790dac

Please sign in to comment.