Skip to content

Support for strict enum mapping #325

Description

@jacob-buckaroo

The problem
The major advantage of using Mapperly over other reflection based solutions like AutoMapper is that we now have mapping validation at build time. This works fine for most objects but not for enums, this is still done at run time when mapping a source object to a destination type.

The solution
A feature that can be enabled for explicit enum mapping. When the feature is enabled Mapperly should enforce that all enum values in the destination enum can be created using the values of the source enum. Possibly using a MapperAttribute. When it's not possible to create all enum values, the build should fail.

Alternatives
Writing unit tests and run them during the build step in the CI/CD pipeline to enforce integrity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions