namespace Ardalis.GuardClauses
{
public static class InvalidEmailGuard
{
public static string InvalidEmail(this IGuardClause guardClause, string email, string parameterName)
{
Guard.Against.NullOrEmpty(email, nameof(email));
var emailSuffix = ".com";
if (!email.EndsWith(emailSuffix))
{
throw new ArgumentException($"Invalid Email - must end in {emailSuffix}", parameterName);
}
return email;
}
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter