Comments (4)
Hi @novafree1, in this particular case you are mapping to an object that has only one property, this is why you encounter this exception. If you call the map
method with null
as a second argument, the default value will be used and no exception will be raised.
Also note that if there are at least two parameters in your constructor, there will be no issue calling the mapper with []
.
I'm not worried by cases like your example, because there is no real added value using Valinor for a use case as simple as the one you described — I guess you were just toying around with the library to see how you could use it in a real project?
from valinor.
Hi!
Thank You for Your response. You done supper useful component. I checked default values on object with several values, yes it's working fine. But I think that behavior of the component should be the same regardless of parameters count. I agree that situation with one default parameter is rare, but it can be. For example when user working with some entity and need to confirm some action. entityId and action is part of the url confirm checkbox is post parameter. If user not confirm checkbox action can not proceed. So missing agree parameter and agree parameter with 0 value should be treated the same.
from valinor.
Hi @novafree1, better late than never 🙂 — #159 should fix this issue. Can you try it out on your side and give feedback?
from valinor.
Fixed with #159.
from valinor.
Related Issues (20)
- `Normalizer`: list of objects with duplicate object inside leads to `CircularReferenceFoundDuringNormalization` HOT 3
- `JsonSerializable` is not respected in `Normalizer` HOT 8
- `Normalizer`: `float` precision HOT 8
- How to serialize object collection, ArrayObject used HOT 1
- Serialization to json - Namespaces are not escaped HOT 1
- Types for parameter `Money\Money::__construct($currency)` do not match: `int|string` (docblock) does not accept `Money\Currency` (native). HOT 1
- Conflict in array shapes with namespaces HOT 2
- Use valinor for a assert() function use case HOT 2
- `enableFlexibleCasting` but just for scalars HOT 1
- Is it possible to infer class union (without interface) HOT 1
- How can I teach Valinor to understand generics of \Ds\Set? HOT 3
- [BUG]: FlexibleCastin with Union types HOT 1
- Issue with variadic parameter contains generics HOT 4
- Custom value casters?
- Fix phpstan error with Symfony Uuid in MapperBuilder class and registerConstructor method
- Crash / Infinite loop when target class constructor accepts `self`
- `JsonNormalizer` creates array JSON when object is passed HOT 3
- Potential Bug in Class Name Resolution
- Static Analysis: psalm errors on model classes even with the plugin enabled
- Make the `Class with a single value` behavior an explicit option HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from valinor.