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
ValidationResultThe validation result.
key
stringThe key to associate the error with.
value
stringThe string to check.
minLength
intThe minimum allowed length.
maxLength
intThe maximum allowed length.
message
stringAn 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
ValidationResultThe validation result.
key
stringThe key to associate the error with.
value
stringThe string to check.
regex
RegexThe regular expression the value must match to pass validation.
message
stringAn 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
ValidationResultThe validation result.
key
stringThe key to associate the error with.
value
stringThe string to check.
message
stringAn 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
ValidationResultThe validation result.
key
stringThe key to associate the error with.
value
stringThe string to check.
message
stringAn optional error message.
Returns
- ValidationResult
The validation result.