You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First things first: thank you for this amazing tool!
I'm using it extensively for a few months now, and I've encountered a usecase/behavior that I think could be slightly enhanced
To my understanding, the following snippet:
Note: this is a "mock" of an actual personal usecase, where I'm not in control of the source, and the only case (and data) that is useful for me to keep (and map), is when elementsOfTypeB is present - which is not the case everytime, and other unwanted fields may be present too.
... which obvisouly make the whole mapping process to fail
I fully understand the pros of having such a behavior (as explained in the docs), but it really feels like it could be explicitely enabled (or at least disabled), just like allowSuperfluousKeys or enableFlexibleCasting (or maybe some other more clever "magic" way?)
I have a few workarounds to solve this atm:
Add a prop elementsOfTypeA to my mapped class (or basically any non-existing nullable prop, with enableFlexibleCasting enabled - so that ArgumentsValues::transformValueForSingleArgument() first condition is triggered)
Create a Modifier that checks and forces the presence of my only wanted field in the source
...
All those workarounds just do not feel like they're "the right" solution to this situation.
WDYT? Am I missing an important "way of working w/ Valinor" here? If not, is there a better solution that comes to your mind than the one I suggested here above?
I could probably make a PR suggestion if necessary.
Thanks for your time and for your work!
The text was updated successfully, but these errors were encountered:
First things first: thank you for this amazing tool!
I'm using it extensively for a few months now, and I've encountered a usecase/behavior that I think could be slightly enhanced
To my understanding, the following snippet:
... Should work perfectly fine, and dump:
The rationale of this expectation is that I've enabled:
allowSuperfluousKeys
option, which allows the unexpected keyelementsOfTypeA
to be present in the source, and simply be ignoredenableFlexibleCasting
option, which should simply convert the absence of an array under the nameelementsOfTypeB
into anempty array
(ornull
, iirc)However
Due to the "flattening" default behavior induced by Class with a single value, source value is converted to
... which obvisouly make the whole mapping process to fail
I fully understand the pros of having such a behavior (as explained in the docs), but it really feels like it could be explicitely enabled (or at least disabled), just like
allowSuperfluousKeys
orenableFlexibleCasting
(or maybe some other more clever "magic" way?)I have a few workarounds to solve this atm:
elementsOfTypeA
to my mapped class (or basically any non-existing nullable prop, withenableFlexibleCasting
enabled - so thatArgumentsValues::transformValueForSingleArgument()
first condition is triggered)Modifier
that checks and forces the presence of my only wanted field in the sourceAll those workarounds just do not feel like they're "the right" solution to this situation.
WDYT? Am I missing an important "way of working w/ Valinor" here? If not, is there a better solution that comes to your mind than the one I suggested here above?
I could probably make a PR suggestion if necessary.
Thanks for your time and for your work!
The text was updated successfully, but these errors were encountered: