From cb18564275735da0614be39371e2e3e7f5467e88 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 2 Feb 2020 14:35:30 +0800 Subject: Add timeline service. --- Timeline/Models/Validation/UsernameValidator.cs | 28 +------------------------ 1 file changed, 1 insertion(+), 27 deletions(-) (limited to 'Timeline/Models/Validation/UsernameValidator.cs') diff --git a/Timeline/Models/Validation/UsernameValidator.cs b/Timeline/Models/Validation/UsernameValidator.cs index d8f3bdc0..87bbf85f 100644 --- a/Timeline/Models/Validation/UsernameValidator.cs +++ b/Timeline/Models/Validation/UsernameValidator.cs @@ -1,35 +1,9 @@ using System; -using System.Linq; -using static Timeline.Resources.Models.Validation.UsernameValidator; namespace Timeline.Models.Validation { - public class UsernameValidator : Validator + public class UsernameValidator : NameValidator { - public const int MaxLength = 26; - - protected override (bool, string) DoValidate(string value) - { - if (value.Length == 0) - { - return (false, MessageEmptyString); - } - - if (value.Length > 26) - { - return (false, MessageTooLong); - } - - foreach ((char c, int i) in value.Select((c, i) => (c, i))) - { - if (!(char.IsLetterOrDigit(c) || c == '-' || c == '_')) - { - return (false, MessageInvalidChar); - } - } - - return (true, GetSuccessMessage()); - } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, -- cgit v1.2.3