blob: f6626a2af69d84b3ae0703732bd68fa0bb8dbb76 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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))
{
}
}
}
|