aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Models/Validation
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-01-29 18:38:41 +0800
committercrupest <crupest@outlook.com>2020-01-29 18:38:41 +0800
commit401a0c86054711bf5ebdce7d7717c9b59bffc2fa (patch)
treedd1cd091ecc2c80943735af4b71b53ef26fc7eee /Timeline/Models/Validation
parentb6043126fae039c58512f60a576b10925b06df4c (diff)
downloadtimeline-401a0c86054711bf5ebdce7d7717c9b59bffc2fa.tar.gz
timeline-401a0c86054711bf5ebdce7d7717c9b59bffc2fa.tar.bz2
timeline-401a0c86054711bf5ebdce7d7717c9b59bffc2fa.zip
...
Diffstat (limited to 'Timeline/Models/Validation')
-rw-r--r--Timeline/Models/Validation/NicknameValidator.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/Timeline/Models/Validation/NicknameValidator.cs b/Timeline/Models/Validation/NicknameValidator.cs
new file mode 100644
index 00000000..f6626a2a
--- /dev/null
+++ b/Timeline/Models/Validation/NicknameValidator.cs
@@ -0,0 +1,26 @@
+using System;
+using static Timeline.Resources.Models.Validation.NicknameValidator;
+
+namespace Timeline.Models.Validation
+{
+ public class NicknameValidator : Validator<string>
+ {
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Already checked in base.")]
+ protected override (bool, string) DoValidate(string value)
+ {
+ if (value.Length > 10)
+ return (false, MessageTooLong);
+
+ return (true, GetSuccessMessage());
+ }
+ }
+
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
+ public class NicknameAttribute : ValidateWithAttribute
+ {
+ public NicknameAttribute() : base(typeof(NicknameValidator))
+ {
+
+ }
+ }
+}