Open aviita opened 9 months ago
@aviita Look at the Guard.IsNotDefault
method, I think Guid.Empty == default(Guid)
so this method will work as you want.
@aviita Look at the
Guard.IsNotDefault
method, I thinkGuid.Empty == default(Guid)
so this method will work as you want.
Thanks. Will do.
Overview
There should be
Guard.IsNotEmpty(Guid)
API to Guard against empty guids. With current API's the same guard can be achieved byGuard.IsTrue(guid != Guid.Empty);
.API breakdown
Note that I would also prefer to override the message in many cases, but without actually writing the argument name my self, so making also the
message
, with default value of empty string, but would only use it for the message if not empty (maybe).Usage example
public class MyClass { private Guid _id;
}
Breaking change?
No
Alternatives
Additional context
We are working with guids a lot in our project and would like to have cleaner guard for empty guids than
Guard.IsTrue(guid == Guid.Empty);
.Verifying for empty Guid is pointless to have, so we only need guard for
IsNotEmpty
.I am new to
Guard
API's, so I might be missing some best practices, but noticed this possible shortcoming in the package immediately when starting to use it in our project. Also searched for Stackoverflow and discussions, but there was no discussion to be found around Guid's and Guard.Help us help you
Yes, I'd like to be assigned to work on this item