I'm super interest in this project, and there is some great stuff here - the simplicity is amazing.
Two things that jump out at me. First is the Validation flow. Validation is obviously super important to ValueObjects to ensure correctness, however the examples show throwing exceptions, which makes sense when provided void Validate() as signature.
Has anyone looked at possible providing an interface to allow a different approach to handling validation errors - or even better an approach using OneOf?
Second thing that stands out is the ToString, I love that it can be overrided to allow you to better display your data, I was wondering if there was an overload available using the IFormatter to allow reusability and culture specific formatting.
Interestingly these two could follow the same the strand, using the bridge pattern in order to surface more interopability.
I do guess however, that making the validation change, it would be harder to stop people using an invalid ValueObject because now it won't throw if something is wrong.
Finally are there any extension libraries to help users serialise these valueobjects to JSON, by overriding the jsonserialiser?
If there are some reasoning behind choosing the above approach, it may be worth adding them to the Readme - which I'm happy to do.
I'm super interest in this project, and there is some great stuff here - the simplicity is amazing.
Two things that jump out at me. First is the Validation flow. Validation is obviously super important to ValueObjects to ensure correctness, however the examples show throwing exceptions, which makes sense when provided
void Validate()as signature.Has anyone looked at possible providing an interface to allow a different approach to handling validation errors - or even better an approach using
OneOf?Second thing that stands out is the ToString, I love that it can be overrided to allow you to better display your data, I was wondering if there was an overload available using the IFormatter to allow reusability and culture specific formatting.
Interestingly these two could follow the same the strand, using the bridge pattern in order to surface more interopability.
I do guess however, that making the validation change, it would be harder to stop people using an invalid ValueObject because now it won't throw if something is wrong.
Finally are there any extension libraries to help users serialise these valueobjects to JSON, by overriding the jsonserialiser?
If there are some reasoning behind choosing the above approach, it may be worth adding them to the Readme - which I'm happy to do.