diff --git a/quickfixj-core/src/main/java/quickfix/DataDictionary.java b/quickfixj-core/src/main/java/quickfix/DataDictionary.java index d41d9ffbf0..f9579064ca 100644 --- a/quickfixj-core/src/main/java/quickfix/DataDictionary.java +++ b/quickfixj-core/src/main/java/quickfix/DataDictionary.java @@ -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: diff --git a/quickfixj-core/src/test/java/quickfix/DataDictionaryTest.java b/quickfixj-core/src/test/java/quickfix/DataDictionaryTest.java index 520361d94d..eb73d9f279 100644 --- a/quickfixj-core/src/test/java/quickfix/DataDictionaryTest.java +++ b/quickfixj-core/src/test/java/quickfix/DataDictionaryTest.java @@ -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; @@ -781,6 +782,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 //