Skip to content

Commit c790dac

Browse files
jonfreedmanchrjohn
authored andcommitted
Do not throw IncorrectDataFormat exception if value is empty and ValidateFieldsHaveValues=N (#207)
* do not throw IncorrectDataFormat exception if value is empty and ValidateFieldsHaveValues=N
1 parent 23aa52c commit c790dac

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

quickfixj-core/src/main/java/quickfix/DataDictionary.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,9 @@ private void checkValidFormat(StringField field) throws IncorrectDataFormat {
697697
if (fieldType == null) {
698698
return;
699699
}
700+
if (!checkFieldsHaveValues && field.getValue().length() == 0) {
701+
return;
702+
}
700703
try {
701704
switch (fieldType) {
702705
case STRING:

quickfixj-core/src/test/java/quickfix/DataDictionaryTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import quickfix.field.BodyLength;
2828
import quickfix.field.CheckSum;
2929
import quickfix.field.ClOrdID;
30+
import quickfix.field.EffectiveTime;
3031
import quickfix.field.HandlInst;
3132
import quickfix.field.LastMkt;
3233
import quickfix.field.MsgSeqNum;
@@ -1275,6 +1276,29 @@ public void testGroupWithReqdComponentWithReqdFieldValidation() throws Exception
12751276
dictionary.validate(quoteRequest, true);
12761277
}
12771278

1279+
/**
1280+
* Field EffectiveTime(168) is defined as UTCTIMESTAMP so an empty string value is invalid but if we allow blank values that should not fail
1281+
* validation
1282+
* @throws Exception
1283+
*/
1284+
@Test
1285+
public void testAllowingBlankValuesDisablesFieldValidation() throws Exception {
1286+
final DataDictionary dictionary = getDictionary();
1287+
dictionary.setCheckFieldsHaveValues(false);
1288+
final quickfix.fix44.NewOrderSingle newSingle = new quickfix.fix44.NewOrderSingle(
1289+
new ClOrdID("123"), new Side(Side.BUY), new TransactTime(), new OrdType(OrdType.LIMIT)
1290+
);
1291+
newSingle.setField(new OrderQty(42));
1292+
newSingle.setField(new Price(42.37));
1293+
newSingle.setField(new HandlInst());
1294+
newSingle.setField(new Symbol("QFJ"));
1295+
newSingle.setField(new HandlInst(HandlInst.MANUAL_ORDER_BEST_EXECUTION));
1296+
newSingle.setField(new TimeInForce(TimeInForce.DAY));
1297+
newSingle.setField(new Account("testAccount"));
1298+
newSingle.setField(new StringField(EffectiveTime.FIELD));
1299+
dictionary.validate(newSingle, true);
1300+
}
1301+
12781302
//
12791303
// Group Validation Tests in RepeatingGroupTest
12801304
//

0 commit comments

Comments
 (0)