Skip to content

Commit 640673a

Browse files
author
zzzprojects
committed
V2.0.11
V2.0.11
1 parent 5591617 commit 640673a

File tree

6 files changed

+73
-2
lines changed

6 files changed

+73
-2
lines changed

src/Z.Core/System.Byte/System.Math/Byte.Max.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ public static Byte Max(this Byte val1, Byte val2)
1818
{
1919
return Math.Max(val1, val2);
2020
}
21-
R
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Description: C# Extension Methods Library to enhances the .NET Framework by adding hundreds of new methods. It drastically increases developers productivity and code readability. Support C# and VB.NET
2+
// Website & Documentation: https://github.com/zzzprojects/Z.ExtensionMethods
3+
// Forum: https://github.com/zzzprojects/Z.ExtensionMethods/issues
4+
// License: https://github.com/zzzprojects/Z.ExtensionMethods/blob/master/LICENSE
5+
// More projects: http://www.zzzprojects.com/
6+
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.
7+
8+
using System;
9+
10+
public static partial class Extensions
11+
{
12+
/// <summary>
13+
/// A string extension method that converts the @this to a valid date time or null.
14+
/// </summary>
15+
/// <param name="this">The @this to act on.</param>
16+
/// <returns>@this as a DateTime?</returns>
17+
public static DateTime? ToValidDateTimeOrNull(this string @this)
18+
{
19+
DateTime date;
20+
21+
if (DateTime.TryParse(@this, out date))
22+
{
23+
return date;
24+
}
25+
26+
return null;
27+
}
28+
}

src/Z.Core/System.String/zzzRegexPattern/String.IsValidEmail.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public static partial class Extensions
1515
/// <returns>true if valid email, false if not.</returns>
1616
public static bool IsValidEmail(this string obj)
1717
{
18-
return Regex.IsMatch(obj, @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
18+
return Regex.IsMatch(obj, @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z0-9]{1,30})(\]?)$");
1919
}
2020
}

src/Z.Core/Z.Core.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@
508508
<Compile Include="System.Single\_CoreObject\Single.In.cs" />
509509
<Compile Include="System.Single\_CoreObject\Single.InRange.cs" />
510510
<Compile Include="System.Single\_CoreObject\Single.NotIn.cs" />
511+
<Compile Include="System.String\String.ToValidDateTimeOrNull.cs" />
511512
<Compile Include="System.String\String.Br2Nl.cs" />
512513
<Compile Include="System.String\String.IsPalindrome.cs" />
513514
<Compile Include="System.String\String.IsAnagram.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Description: C# Extension Methods Library to enhances the .NET Framework by adding hundreds of new methods. It drastically increases developers productivity and code readability. Support C# and VB.NET
2+
// Website & Documentation: https://github.com/zzzprojects/Z.ExtensionMethods
3+
// Forum: https://github.com/zzzprojects/Z.ExtensionMethods/issues
4+
// License: https://github.com/zzzprojects/Z.ExtensionMethods/blob/master/LICENSE
5+
// More projects: http://www.zzzprojects.com/
6+
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.
7+
using System;
8+
using Microsoft.VisualStudio.TestTools.UnitTesting;
9+
10+
namespace Z.Core.Test
11+
{
12+
[TestClass]
13+
public class System_String_IsValidEmail
14+
{
15+
[TestMethod]
16+
public void IsValidEmail()
17+
{
18+
{
19+
// Type
20+
string @this = "test@hotmail.com";
21+
22+
// Exemples
23+
var result = @this.IsValidEmail(); // return true;
24+
25+
// Unit Test
26+
Assert.IsTrue(result);
27+
}
28+
29+
{
30+
// Type
31+
string @this = "mike@GOTBLOG.ONLINE";
32+
33+
// Exemples
34+
var result = @this.IsValidEmail(); // return true;
35+
36+
// Unit Test
37+
Assert.IsTrue(result);
38+
}
39+
}
40+
}
41+
}

test/Z.Core.Test/Z.Core.Test.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
<ItemGroup>
6363
<Compile Include="Properties\AssemblyInfo.cs" />
6464
<Compile Include="System.Object\Object.Try.cs" />
65+
<Compile Include="System.String\String.IsValidEmail.cs" />
6566
<Compile Include="System.String\String.IsPalindrome.cs" />
6667
<Compile Include="System.String\String.IsAnagram.cs" />
6768
<Compile Include="System.Array\Array.ClearAll.cs" />

0 commit comments

Comments
 (0)