Table of Contents

Class StringValidationExtensions

Namespace
Admonish
Assembly
Admonish.dll

Contains string validation extension methods of ValidationResult.

public static class StringValidationExtensions
Inheritance
StringValidationExtensions
Inherited Members

Methods

LengthBetween(ValidationResult, string, string?, int, int, string?)

Ensures that the length of the specified string is within the specified range (inclusive). When the check fails, adds an error message to the ValidationResult and associates it with the specified key.

public static ValidationResult LengthBetween(this ValidationResult r, string key, string? value, int minLength, int maxLength, string? message = null)

Parameters

r ValidationResult

The validation result.

key string

The key to associate the error with.

value string

The string to check.

minLength int

The minimum allowed length.

maxLength int

The maximum allowed length.

message string

An optional error message.

Returns

ValidationResult

The validation result.

Matches(ValidationResult, string, string?, Regex, string?)

Ensures that the specified string matches the specified regular expression. When the check fails, adds an error message to the ValidationResult and associates it with the specified key.

public static ValidationResult Matches(this ValidationResult r, string key, string? value, Regex regex, string? message = null)

Parameters

r ValidationResult

The validation result.

key string

The key to associate the error with.

value string

The string to check.

regex Regex

The regular expression the value must match to pass validation.

message string

An optional error message.

Returns

ValidationResult

The validation result.

NonNullOrEmpty(ValidationResult, string, string?, string?)

Ensures that the specified string is not null or empty. When it is, adds an error message to the ValidationResult and associates it with the specified key.

public static ValidationResult NonNullOrEmpty(this ValidationResult r, string key, string? value, string? message = null)

Parameters

r ValidationResult

The validation result.

key string

The key to associate the error with.

value string

The string to check.

message string

An optional error message.

Returns

ValidationResult

The validation result.

NonNullOrWhiteSpace(ValidationResult, string, string?, string?)

Ensures that the specified string is not null or empty or consists of whitespace characters only. When the check fails, adds an error message to the ValidationResult and associates it with the specified key.

public static ValidationResult NonNullOrWhiteSpace(this ValidationResult r, string key, string? value, string? message = null)

Parameters

r ValidationResult

The validation result.

key string

The key to associate the error with.

value string

The string to check.

message string

An optional error message.

Returns

ValidationResult

The validation result.