From 09efa662a3ed01ba9c7ab7445e97a4df346f3253 Mon Sep 17 00:00:00 2001 From: Aaron Lord Date: Sun, 14 Feb 2016 12:52:46 -0800 Subject: [PATCH] Allow creation of patients without email addresses --- .../PatientOnBoardShortDetail.cs | 4 ++-- .../PatientOnBoardShortDetailValidationTests.cs | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/SnapMD.ConnectedCare.ApiModels/PatientOnBoardShortDetail.cs b/SnapMD.ConnectedCare.ApiModels/PatientOnBoardShortDetail.cs index 6957029d..9c7cff0f 100644 --- a/SnapMD.ConnectedCare.ApiModels/PatientOnBoardShortDetail.cs +++ b/SnapMD.ConnectedCare.ApiModels/PatientOnBoardShortDetail.cs @@ -44,7 +44,7 @@ public class PatientOnBoardShortDetail public PatientOnBoardStatus? Status { get; set; } public bool? PreventSendingInvitation { get; set; } - public bool ValidateModel(Func exceptionToThrow = null) + public bool ValidateModel(Func exceptionToThrow = null, bool allowNullEmail = false) { if (exceptionToThrow == null) { @@ -57,7 +57,7 @@ public bool ValidateModel(Func exceptionToThrow = null) throw exceptionToThrow("First name required."); } - if (string.IsNullOrEmpty(Email)) + if (!allowNullEmail && string.IsNullOrWhiteSpace(Email)) { // error: email required. throw exceptionToThrow("Email address required."); diff --git a/SnapMD.ConnectedCare.Sdk.Tests/ModelTests/PatientOnBoardShortDetailValidationTests.cs b/SnapMD.ConnectedCare.Sdk.Tests/ModelTests/PatientOnBoardShortDetailValidationTests.cs index 3e1663cf..7cc9fde8 100644 --- a/SnapMD.ConnectedCare.Sdk.Tests/ModelTests/PatientOnBoardShortDetailValidationTests.cs +++ b/SnapMD.ConnectedCare.Sdk.Tests/ModelTests/PatientOnBoardShortDetailValidationTests.cs @@ -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); + } } }