Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HasValue and IsEmpty properties #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cieciurm
Copy link

Hi @mcintyre321,

Thanks for your awesome work on ValueOf.

I was trying it out and everything is great, except for the fact that I was missing a way to check if the identifier was actually initialized with a value. So I thought adding two properties:

  • HasValue - which checks if the Value was set
  • IsEmpty - which is a negation of HasValue

could be a small tweak for this small library.

Please let me know if it works for you. If there is something I can adjust, just let me know.

Thanks,
Mateusz

BTW. I also took the liberty and updated package versions for the Test project.

@mcintyre321
Copy link
Owner

mcintyre321 commented Mar 25, 2023 via email

@cieciurm
Copy link
Author

Currently, if you instantiate a new object deriving from ValueOf it doesn't have a Value set.

Example:

public class StringId : ValueOf<string, StringId> { }

var id = new StringId();

The Value would be equal to the default value of string, so null.

When I was trying out the library for the first time, that's how I created an instance of my identifier. I didn't notice that there was a .From method.

So, I think that having those properties could be helpful in other parts of codebase to determine whether the identifier has been initialized from a value, or is it being created without specifying it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants