aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Models
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
commit81c261b59016e15d320ad963882afe4d9c7b5f7d (patch)
treedd1cd091ecc2c80943735af4b71b53ef26fc7eee /Timeline/Models
parent2750a3df1834c1c6623aa8c653504c7bc12cefd6 (diff)
downloadtimeline-81c261b59016e15d320ad963882afe4d9c7b5f7d.tar.gz
timeline-81c261b59016e15d320ad963882afe4d9c7b5f7d.tar.bz2
timeline-81c261b59016e15d320ad963882afe4d9c7b5f7d.zip
...
Diffstat (limited to 'Timeline/Models')
-rw-r--r--Timeline/Models/User.cs1
-rw-r--r--Timeline/Models/Validation/NicknameValidator.cs26
2 files changed, 27 insertions, 0 deletions
diff --git a/Timeline/Models/User.cs b/Timeline/Models/User.cs
index 05395022..2cead892 100644
--- a/Timeline/Models/User.cs
+++ b/Timeline/Models/User.cs
@@ -12,6 +12,7 @@ namespace Timeline.Models
#region secret
+ public long? Id { get; set; }
public string? Password { get; set; }
public long? Version { get; set; }
#endregion secret
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))
+ {
+
+ }
+ }
+}