Giter Site home page Giter Site logo

Enum fallback value about auto_mappr HOT 2 CLOSED

DevNico avatar DevNico commented on May 29, 2024 1
Enum fallback value

from auto_mappr.

Comments (2)

DevNico avatar DevNico commented on May 29, 2024 1

I'll take a look at this, you can assign me to this issue.

from auto_mappr.

tenhobi avatar tenhobi commented on May 29, 2024

Hi @DevNico, that's a good catch!

Right now, we require that the target is a superset of the source. And from the implementation (https://github.com/netglade/auto_mappr/blob/main/packages/auto_mappr/lib/src/builder/enum_assignment_builder.dart#L15), we probably forgot that if null is passed, we should return the whenSourceIsNull if present, that should also be added.

To comply with the mentioned requirement, we can relax it when the whenSourceIsNull argument is set and don't enforce it, and if that happens, return that value instead, aka your 'fallback enum value'. 👍

With something like this:

values.firstWhere((x) => x.name == model.name, orElse: () => whenSourceIsNull)

Let us know if you want to take this issue and implement the changes. We can also discuss it on our Discord. 🙌

from auto_mappr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.