diff options
author | 杨宇千 <crupest@outlook.com> | 2020-02-03 18:38:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-03 18:38:14 +0800 |
commit | e5fb17ddfc3d1ecf0b283c8cc1a91fb2a2a03236 (patch) | |
tree | 28ef20f9dfe742008bb934f09b99d1d4719cabaa /Timeline/Models/Validation/UsernameValidator.cs | |
parent | 673fa5f0645308bfa8d17dc4e0e145bbaf239329 (diff) | |
parent | 86c4e7834bf25b900af03edc53aea3f37f645334 (diff) | |
download | timeline-e5fb17ddfc3d1ecf0b283c8cc1a91fb2a2a03236.tar.gz timeline-e5fb17ddfc3d1ecf0b283c8cc1a91fb2a2a03236.tar.bz2 timeline-e5fb17ddfc3d1ecf0b283c8cc1a91fb2a2a03236.zip |
Merge pull request #57 from crupest/dev
Add normal timeline feature.
Diffstat (limited to 'Timeline/Models/Validation/UsernameValidator.cs')
-rw-r--r-- | Timeline/Models/Validation/UsernameValidator.cs | 28 |
1 files changed, 1 insertions, 27 deletions
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<string>
+ 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,
|