Skip to content

fixing enum compare to be case insensitive for FFEnumParseString#217

Merged
peterbroadhurst merged 2 commits into
hyperledger:mainfrom
kaleido-io:fixing-enum-compare
Jun 10, 2026
Merged

fixing enum compare to be case insensitive for FFEnumParseString#217
peterbroadhurst merged 2 commits into
hyperledger:mainfrom
kaleido-io:fixing-enum-compare

Conversation

@Chengxuan

Copy link
Copy Markdown
Contributor

Among all functions apart from Value() , the usage of enum values follows a case-insensitive pattern and treats lower case as canonical.

This PR updates the FFEnumParseString to also be case-insensitive when looking up a string against registered values.

Signed-off-by: Chengxuan Xing <chengxuan.xing@kaleido.io>
@Chengxuan Chengxuan requested a review from a team as a code owner June 5, 2026 15:07
Comment thread pkg/fftypes/enum.go Outdated
for _, possible := range e {
if possible == strings.ToLower(val) {
return FFEnum(strings.ToLower(val)), nil
possibleStr, ok := possible.(string)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just (string)possible simple type casting should be possible here for a known type, rather than interface

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. conversion to interface{} is only needed for FFEnumValues as that function is used for openapi.

Updated the code to make that clear.

Signed-off-by: Chengxuan Xing <chengxuan.xing@kaleido.io>

@peterbroadhurst peterbroadhurst left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@peterbroadhurst peterbroadhurst merged commit f86c8c9 into hyperledger:main Jun 10, 2026
3 checks passed
@Chengxuan Chengxuan deleted the fixing-enum-compare branch June 10, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants