From 9e0fbac6d3cb4e11efdb33c339ccf0adbca0bc6c Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Thu, 1 Apr 2021 22:36:59 +0200 Subject: Initial commit --- src/IOL.Helpers/Validators.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/IOL.Helpers/Validators.cs (limited to 'src/IOL.Helpers/Validators.cs') diff --git a/src/IOL.Helpers/Validators.cs b/src/IOL.Helpers/Validators.cs new file mode 100644 index 0000000..d60afcf --- /dev/null +++ b/src/IOL.Helpers/Validators.cs @@ -0,0 +1,18 @@ +using System.Net.Mail; +using System.Text.RegularExpressions; + +namespace IOL.Helpers +{ + public static class Validators + { + private static readonly Regex _norwegianPhoneNumber = new(@"^(0047|\+47|47)?[2-9]\d{7}$"); + + public static bool IsValidEmailAddress(this string value) { + return MailAddress.TryCreate(value, out _); + } + + public static bool IsValidNorwegianPhoneNumber(this string value) { + return _norwegianPhoneNumber.IsMatch(value); + } + } +} \ No newline at end of file -- cgit v1.3