Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting to allow disabling of enumeration validation. #646

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion QuickFIXn/DataDictionary/DataDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class DataDictionary
public bool CheckUserDefinedFields { get; set; }
public bool AllowUnknownMessageFields { get; set; }

public bool CheckEnumValues { get; set; }

public DDMap Header = new DDMap();
public DDMap Trailer = new DDMap();

Expand All @@ -33,6 +35,7 @@ public DataDictionary()
CheckFieldsHaveValues = true;
CheckFieldsOutOfOrder = true;
CheckUserDefinedFields = true;
CheckEnumValues = true;
AllowUnknownMessageFields = false;
}

Expand Down Expand Up @@ -75,6 +78,7 @@ public DataDictionary(DataDictionary src)
this.CheckFieldsHaveValues = src.CheckFieldsHaveValues;
this.CheckFieldsOutOfOrder = src.CheckFieldsOutOfOrder;
this.CheckUserDefinedFields = src.CheckUserDefinedFields;
this.CheckEnumValues = src.CheckEnumValues;
this.Header = src.Header;
this.Trailer = src.Trailer;
}
Expand Down Expand Up @@ -353,7 +357,7 @@ public void CheckValue(Fields.IField field)
{
if (FieldsByTag.TryGetValue(field.Tag, out var fld))
{
if (fld.HasEnums())
if (fld.HasEnums() && this.CheckEnumValues)
{
if (fld.IsMultipleValueFieldWithEnums)
{
Expand Down
2 changes: 2 additions & 0 deletions QuickFIXn/SessionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ protected DataDictionary.DataDictionary createDataDictionary(SessionID sessionID
ddCopy.CheckUserDefinedFields = settings.GetBool(SessionSettings.VALIDATE_USER_DEFINED_FIELDS);
if (settings.Has(SessionSettings.ALLOW_UNKNOWN_MSG_FIELDS))
ddCopy.AllowUnknownMessageFields = settings.GetBool(SessionSettings.ALLOW_UNKNOWN_MSG_FIELDS);
if (settings.Has(SessionSettings.VALIDATE_ENUM_VALUES))
ddCopy.CheckEnumValues = settings.GetBool(SessionSettings.VALIDATE_ENUM_VALUES);

return ddCopy;
}
Expand Down
1 change: 1 addition & 0 deletions QuickFIXn/SessionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class SessionSettings
public const string RESET_ON_LOGON = "ResetOnLogon";
public const string RESET_ON_LOGOUT = "ResetOnLogout";
public const string RESET_ON_DISCONNECT = "ResetOnDisconnect";
public const string VALIDATE_ENUM_VALUES = "ValidateEnumValues";
public const string VALIDATE_FIELDS_OUT_OF_ORDER = "ValidateFieldsOutOfOrder";
public const string VALIDATE_FIELDS_HAVE_VALUES = "ValidateFieldsHaveValues";
public const string VALIDATE_USER_DEFINED_FIELDS = "ValidateUserDefinedFields";
Expand Down
6 changes: 6 additions & 0 deletions UnitTests/DataDictionaryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ public void CheckValue()
// multiple-value field, one value is invalid
Assert.Throws(typeof(IncorrectTagValue),
delegate { dd.CheckValue(new QuickFix.Fields.QuoteCondition("A @ D")); });


dd.CheckEnumValues = false;
dd.CheckValue(new QuickFix.Fields.TickDirection('9'));
dd.CheckValue(new QuickFix.Fields.QuoteCondition("A @ D"));
}

[Test]
Expand Down Expand Up @@ -298,6 +303,7 @@ public void CheckIsInGroupTest()
}

[Test]
[Category("Integration")]
public void CheckGroupCountTest()
{
QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary();
Expand Down