Vogen icon indicating copy to clipboard operation
Vogen copied to clipboard

allow to default

Open dzmitry-lahoda opened this issue 2 years ago • 1 comments

[ValueObject(typeof(int), Default = bool)]

So allow default for whatever reason I want. In this case, Value should be public get/set. Or will not be able to set it. Still prevent direct creation of values (so kind of only reflection can do that).

dzmitry-lahoda avatar Jan 23 '22 08:01 dzmitry-lahoda

in this case it seems then resonable to impl https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.ivalidatableobject.validate .

so kind of can serde it from data, but reflection of serde respects validity

dzmitry-lahoda avatar Jan 23 '22 08:01 dzmitry-lahoda

Apologies, I must've missed this issue. Making Value settable violates the immutable aspect of value objects.

There are defaultable 'instances' that you can create, please see: https://github.com/SteveDunn/Vogen/wiki/Instances

SteveDunn avatar Jul 17 '23 06:07 SteveDunn