Table of Contents

Class RegexRule

Namespace
Apq.Cfg.Validation.Rules
Assembly
Apq.Cfg.dll

正则表达式验证规则

public sealed class RegexRule : IValidationRule
Inheritance
RegexRule
Implements
Inherited Members

Constructors

RegexRule(string, string, string?, RegexOptions)

创建正则表达式验证规则

public RegexRule(string key, string pattern, string? errorMessage = null, RegexOptions options = RegexOptions.None)

Parameters

key string

配置键

pattern string

正则表达式模式

errorMessage string

自定义错误消息

options RegexOptions

正则表达式选项

Properties

ErrorMessage

自定义错误消息

public string? ErrorMessage { get; }

Property Value

string

Key

要验证的配置键

public string Key { get; }

Property Value

string

Name

规则名称

public string Name { get; }

Property Value

string

Pattern

正则表达式模式

public string Pattern { get; }

Property Value

string

Methods

Validate(string?)

验证配置值

public ValidationError? Validate(string? value)

Parameters

value string

配置值

Returns

ValidationError

验证错误,如果验证通过返回 null