Validate email for member models (#17532)
* Validate email for member models * Add null check or more test cases * return invalid when not a valid email * Cleanup * remove private method in favor of extension * Remove non used, using statement --------- Co-authored-by: Elitsa <elm@umbraco.dk>
This commit is contained in:
@@ -364,6 +364,16 @@ public class StringExtensionsTests
|
||||
TryIsFullPath(" ", false, false); // technically, a valid filename on Linux
|
||||
}
|
||||
|
||||
[TestCase("test@test.com", true)]
|
||||
[TestCase("test@test", true)]
|
||||
[TestCase("testtest.com", false)]
|
||||
[TestCase("test@test.dk", true)]
|
||||
[TestCase("test@test.se", true)]
|
||||
[TestCase(null, false)]
|
||||
[TestCase("", false)]
|
||||
[TestCase(" ", false)]
|
||||
public void IsEmail(string? email, bool isEmail) => Assert.AreEqual(isEmail, email.IsEmail());
|
||||
|
||||
private static void TryIsFullPath(string path, bool expectedIsFull, bool expectedIsValid = true)
|
||||
{
|
||||
Assert.AreEqual(expectedIsFull, path.IsFullPath(), "IsFullPath('" + path + "')");
|
||||
|
||||
Reference in New Issue
Block a user