Validate each token of multi-value enum fields#766
Open
vsaraikin wants to merge 1 commit into
Open
Conversation
MULTIPLEVALUESTRING/MULTIPLESTRINGVALUE/MULTIPLECHARVALUE fields carry a space-delimited set of enum tokens, but validateField looked up the whole value in the enum map, so any legal combination of two or more values (e.g. ExecInst "1 5") was rejected as out of range. Split on space and validate each component. Fixes quickfixgo#754.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #754.
Fields of type
MULTIPLEVALUESTRING/MULTIPLESTRINGVALUE/MULTIPLECHARVALUEcarry a space-delimited set of enum tokens (per the FIX spec, e.g.ExecInst = "1 5"means NOTHELD + HELD).validateFieldlooked the entire raw value up in the enum map:so any legal combination of two or more values was rejected with
ValueIsIncorrect("out of range"), even though each token is individually valid. Single-value fields still passed, which masked the bug.Fix
For the three multi-value field types, split the value on
' 'and validate every component against the enum map; all other types keep the original single-lookup path.Testing
Added two cases to
TestValidate(FIX.4.3,ExecInsttag 18, aMULTIPLEVALUESTRING):"Y M"(two valid ExecInst enums) → accepted. Fails on the current code (Unexpected reject: Value is incorrect), passes with the fix."Y ZZ"(one valid, one invalid token) → still correctly rejected withValueIsIncorrectand the right ref tag.The full package suite passes with no regression;
gofmtclean.Note: the code generator (
cmd/generate-fix/internal/template_helpers.go) has the analogous single-lookup pattern in generated per-field setters — happy to follow up on that separately if you'd like it addressed too.