question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enums are not case insensitive

See original GitHub issue

First off: great job, guys!

Small issue: it looks like even though the wiki states that option properties bound to enum values are case insensitive:

When specifying enum values, you don’t need to respect case. Both app -g bye and app --greet-type REGARDS are allowed.

unfortunately, they are not. I have a program that for a line like this:

settings -s gogo -v 23 -t int

where -t is bound to an enum SettingType {Int, String, ...}, I get an error:

ERROR(S):
  Option 't, type' is defined with a bad format.

  -s, --setting      The name of a setting to be added or modified.

  -v, --value        The new value of the setting. The option is required if -s or --setting is specified.

  -t, --type         (Default: String) The case-sensitive type of the value of the setting. The option is not mandatory and if not specified, the
                     type will be either implied from the existing setting with the same name or it will be assumed to be 'String'. The most common
                     types are: String, Int, Guid, Decimal, Boolean, DateTime, Date, Time, Uri, TimeSpan. DateTime values are assumed to be UTC.

[...etc]

BadFormatConversionError
  StopsProcessing          = False
  Tag                      = ErrorType.BadFormatConversionError
  NameInfo                 = NameInfo
    LongName                 = type
    NameText                 = t, type
    ShortName                = t

But if I enter the command like this:

settings -s gogo -v 23 -t Int

all is good.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
giuliovcommented, Jul 18, 2018

It would be nice if you merge this PR after so many months.

2reactions
harlam357commented, Jan 9, 2018

Also experiencing the same issue using the latest v2.2.0 package. Setting CaseInsensitiveEnumValues = true has no effect.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Case-insensitive matching of a string to a Java enum
valueOf("Monday");. If the string passed to valueOf() does not match (case sensitive) an existing Day value, an IllegalArgumentException ...
Read more >
Case Insensitive Enum Mapping in Spring Boot
In this tutorial, we'll shed light on how to handle enum mapping in a case-insensitive manner when passing it as request parameter in...
Read more >
How to decode enums ignoring case in Swift Codable
The default behavior for enums decoding is case-sensitive comparison, meaning "MEMBER" and "Member" will fail our decoding. You will get a fatal ...
Read more >
Spring Boot: How to ignore case when using an Enum as a ...
Here is a way to enable the use of case-insensitive enumerations request parameters. You won't need to do any code modification in your...
Read more >
proposal: case-insensitive enum
In my opinion, the simplest solution is just to add a "caseInsensitive" flag or something similar to the standard. There are other use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found