Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
Allow creation of patients without email addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
lorddev committed Feb 14, 2016
1 parent 9222b4e commit 09efa66
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions SnapMD.ConnectedCare.ApiModels/PatientOnBoardShortDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class PatientOnBoardShortDetail
public PatientOnBoardStatus? Status { get; set; }
public bool? PreventSendingInvitation { get; set; }

public bool ValidateModel(Func<string, Exception> exceptionToThrow = null)
public bool ValidateModel(Func<string, Exception> exceptionToThrow = null, bool allowNullEmail = false)
{
if (exceptionToThrow == null)
{
Expand All @@ -57,7 +57,7 @@ public bool ValidateModel(Func<string, Exception> exceptionToThrow = null)
throw exceptionToThrow("First name required.");
}

if (string.IsNullOrEmpty(Email))
if (!allowNullEmail && string.IsNullOrWhiteSpace(Email))
{
// error: email required.
throw exceptionToThrow("Email address required.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,20 @@ public void TestModelValidationFail()
bool actual = target.ValidateModel(m => new Exception(m));
Assert.IsTrue(actual);
}

[Test]
public void TestModelValidationAllowsNullEmail()
{
var target = new PatientOnBoardShortDetail
{
FirstName = "First Name",
Email = null,
Dob = new DateTime(2015, 1, 1),
Address = "I.R. Address",
MobileNumberWithCountryCode = "12345678900"
};
bool actual = target.ValidateModel(m => new Exception(m), true);
Assert.IsTrue(actual);
}
}
}

0 comments on commit 09efa66

Please sign in to comment.