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

Commit 09efa66

Browse files
committed
Allow creation of patients without email addresses
1 parent 9222b4e commit 09efa66

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

SnapMD.ConnectedCare.ApiModels/PatientOnBoardShortDetail.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class PatientOnBoardShortDetail
4444
public PatientOnBoardStatus? Status { get; set; }
4545
public bool? PreventSendingInvitation { get; set; }
4646

47-
public bool ValidateModel(Func<string, Exception> exceptionToThrow = null)
47+
public bool ValidateModel(Func<string, Exception> exceptionToThrow = null, bool allowNullEmail = false)
4848
{
4949
if (exceptionToThrow == null)
5050
{
@@ -57,7 +57,7 @@ public bool ValidateModel(Func<string, Exception> exceptionToThrow = null)
5757
throw exceptionToThrow("First name required.");
5858
}
5959

60-
if (string.IsNullOrEmpty(Email))
60+
if (!allowNullEmail && string.IsNullOrWhiteSpace(Email))
6161
{
6262
// error: email required.
6363
throw exceptionToThrow("Email address required.");

SnapMD.ConnectedCare.Sdk.Tests/ModelTests/PatientOnBoardShortDetailValidationTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,20 @@ public void TestModelValidationFail()
3838
bool actual = target.ValidateModel(m => new Exception(m));
3939
Assert.IsTrue(actual);
4040
}
41+
42+
[Test]
43+
public void TestModelValidationAllowsNullEmail()
44+
{
45+
var target = new PatientOnBoardShortDetail
46+
{
47+
FirstName = "First Name",
48+
Email = null,
49+
Dob = new DateTime(2015, 1, 1),
50+
Address = "I.R. Address",
51+
MobileNumberWithCountryCode = "12345678900"
52+
};
53+
bool actual = target.ValidateModel(m => new Exception(m), true);
54+
Assert.IsTrue(actual);
55+
}
4156
}
4257
}

0 commit comments

Comments
 (0)