Class LengthRule
- Namespace
- Apq.Cfg.Validation.Rules
- Assembly
- Apq.Cfg.dll
字符串长度验证规则
public sealed class LengthRule : IValidationRule
- Inheritance
-
LengthRule
- Implements
- Inherited Members
Constructors
LengthRule(string, int?, int?, string?)
创建字符串长度验证规则
public LengthRule(string key, int? minLength = null, int? maxLength = null, string? errorMessage = null)
Parameters
keystring配置键
minLengthint?最小长度(null 表示不限制)
maxLengthint?最大长度(null 表示不限制)
errorMessagestring自定义错误消息
Properties
ErrorMessage
自定义错误消息
public string? ErrorMessage { get; }
Property Value
Key
要验证的配置键
public string Key { get; }
Property Value
Name
规则名称
public string Name { get; }
Property Value
Methods
Validate(string?)
验证配置值
public ValidationError? Validate(string? value)
Parameters
valuestring配置值
Returns
- ValidationError
验证错误,如果验证通过返回 null