Table of Contents

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

key string

配置键

minLength int?

最小长度(null 表示不限制)

maxLength int?

最大长度(null 表示不限制)

errorMessage string

自定义错误消息

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

Methods

Validate(string?)

验证配置值

public ValidationError? Validate(string? value)

Parameters

value string

配置值

Returns

ValidationError

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