reagento / adaptix

An extremely flexible and configurable data model conversion library.
https://adaptix.readthedocs.io
Apache License 2.0
365 stars 23 forks source link

Add provider for Flag representing its values by names #197

Closed zhPavel closed 7 months ago

zhPavel commented 2 years ago
class Color(Flag):
    RED = auto()
    BLUE = auto()
    GREEN = auto()
    WHITE = RED | BLUE | GREEN

Color.RED -> ['RED'] Color.RED | Color.BLUE -> ['RED', 'BLUE']

The provider should have such options:

  1. Interpret string as a list of one element or forbid this
  2. Forbid duplicating values at list parsing
  3. Use special names for compound values (e.g. Color.RED | Color.BLUE | GREEN -> ['WHITE'])