wip: 🧠 初步的框架

This commit is contained in:
tk
2023-08-25 15:33:42 +08:00
parent 57c1ba2002
commit 18b4d7547a
1014 changed files with 122380 additions and 2 deletions

View File

@ -0,0 +1,34 @@
namespace NetAdmin.Domain.Attributes.DataValidation;
/// <summary>
/// 用户名验证器
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter)]
public sealed class UserNameAttribute : RegexAttribute
{
/// <summary>
/// Initializes a new instance of the <see cref="UserNameAttribute" /> class.
/// </summary>
public UserNameAttribute() //
: base(Chars.RGX_USERNAME)
{
ErrorMessageResourceType = typeof(Ln);
}
/// <inheritdoc />
public override bool IsValid(object value)
{
if (!base.IsValid(value)) {
ErrorMessageResourceName = nameof(Ln.4);
return false;
}
if (!new MobileAttribute().IsValid(value)) {
return true;
}
// 不能是手机号
ErrorMessageResourceName = nameof(Ln.);
return false;
}
}