Allow Choice to ignore case by passing an optional parameter to its __init__ method.
When applied, the filter should return the matching choice (i.e., automatically "fix" case mismatch).
Example:
>>> Choice(choices={'MOE', 'LARRY', 'CURLY', 'SHEMP'}, case_sensitive=False)\
... .apply('Moe')
MOE # (changed to UPPERCASE to match valid choice)
Note that this yields a different result than using case folding:
>>> (CaseFold | Choice(choices={'MOE', 'LARRY', 'CURLY', 'SHEMP'}))\
... .apply('Moe')
# Input is case-folded before Choice filter sees it, so it doesn't match anything.
FilterError: Valid options are: ['CURLY', 'LARRY', 'MOE', 'SHEMP']
Allow
Choiceto ignore case by passing an optional parameter to its__init__method.When applied, the filter should return the matching choice (i.e., automatically "fix" case mismatch).
Example:
Note that this yields a different result than using case folding: