3

If validation is on in QuickFix/J, the received FIX message is validated against the FIX dictionary configured for Fix engine.

ValidateIncomingMessage| Allow to bypass the message validation (against the dictionary). Default is "Y".

Is there any utility class or method present in QuickFix/J which provides me this functionality to validate a sample Fix message against a Fix dictionary?

Amit Bhati
  • 5,569
  • 1
  • 24
  • 45

2 Answers2

2

You want to use DataDictionary.validate()

            DataDictionary dataDictionary = new DataDictionary( pathToDictionary );
            Message quickfixMessage = new Message( message, dataDictionary );
            dataDictionary.validate( quickfixMessage );

where message is the fix message. QuickfixJ includes some dictionaries in the etc folder.

Alex Colomb
  • 170
  • 8
0

If you have a specific String that you would like to validate, quickfix.Message has a constructor that lets you do this:

public Message(String string,
       DataDictionary dd,
       boolean validate)
        throws InvalidMessage

And can be used like this, for example.

DataDictionary myDict = new DataDictionary(dictionaryPathHere);
Message myMessage = new Message(messageString, myDict, true);
// If this doesn't throw an exception, the message was successfully validated against the dictionary.
Kirill
  • 449
  • 3
  • 11
  • 2
    This will only validate repeating groups in the message against the dictionary then validate the checksum. It will NOT validate non group fields against the dictionary. – Alex Colomb Jun 24 '20 at 20:17
  • Just to support above comment ... https://github.com/quickfix/quickfix/blob/12ae2153f6e91c9bf30cc53e83742d983eec66ff/src/C%2B%2B/Message.cpp#L597 – ryan Feb 24 '23 at 05:20