Skip to content

Support case insensitive string enum values #166

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

Closed
k-paxian opened this issue Oct 13, 2021 · 0 comments
Closed

Support case insensitive string enum values #166

k-paxian opened this issue Oct 13, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@k-paxian
Copy link
Owner

Instead of doing that:

@jsonSerializable
enum RecordType { asset, series }

final customAdapter = JsonMapperAdapter(
    enumValues: {
      RecordType: EnumDescriptor(
          values: RecordType.values,
          mapping: <RecordType, String>{
            RecordType.asset: 'Asset',
            RecordType.series: 'Series'
          })
    });

should be like this:

@jsonSerializable
enum RecordType { asset, series }

final customAdapter = JsonMapperAdapter(
    enumValues: {
      RecordType: EnumDescriptor(
          values: RecordType.values,
          caseInsensitive: true
    });

Inspired by this

@k-paxian k-paxian added the enhancement New feature or request label Oct 13, 2021
@k-paxian k-paxian self-assigned this Oct 13, 2021
k-paxian added a commit that referenced this issue Oct 17, 2021
#168 (feat) Improve `fromMap` and `toMap` efficiency
#166 (feat) Support `caseInsensitive` flag for string enum values defined using `EnumDescriptor`
#167 Cover unbalanced types with getter/setter case with unit test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant