Class CustomRule
- Namespace
- Apq.Cfg.Validation.Rules
- Assembly
- Apq.Cfg.dll
自定义验证规则
public sealed class CustomRule : IValidationRule
- Inheritance
-
CustomRule
- Implements
- Inherited Members
Constructors
CustomRule(string, Func<string?, bool>, string, string?)
创建自定义验证规则
public CustomRule(string key, Func<string?, bool> validator, string errorMessage, string? ruleName = null)
Parameters
keystring配置键
validatorFunc<string, bool>验证函数,返回 true 表示验证通过
errorMessagestring错误消息
ruleNamestring规则名称
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