diff options
author | crupest <crupest@outlook.com> | 2020-01-29 18:38:41 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-01-29 18:38:41 +0800 |
commit | 81c261b59016e15d320ad963882afe4d9c7b5f7d (patch) | |
tree | dd1cd091ecc2c80943735af4b71b53ef26fc7eee /Timeline/Models | |
parent | 2750a3df1834c1c6623aa8c653504c7bc12cefd6 (diff) | |
download | timeline-81c261b59016e15d320ad963882afe4d9c7b5f7d.tar.gz timeline-81c261b59016e15d320ad963882afe4d9c7b5f7d.tar.bz2 timeline-81c261b59016e15d320ad963882afe4d9c7b5f7d.zip |
...
Diffstat (limited to 'Timeline/Models')
-rw-r--r-- | Timeline/Models/User.cs | 1 | ||||
-rw-r--r-- | Timeline/Models/Validation/NicknameValidator.cs | 26 |
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))
+ {
+
+ }
+ }
+}
|