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
rValidationResultThe validation result.
keystringThe key to associate the error with.
valuestringThe string to check.
minLengthintThe minimum allowed length.
maxLengthintThe maximum allowed length.
messagestringAn 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
rValidationResultThe validation result.
keystringThe key to associate the error with.
valuestringThe string to check.
regexRegexThe regular expression the value must match to pass validation.
messagestringAn 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
rValidationResultThe validation result.
keystringThe key to associate the error with.
valuestringThe string to check.
messagestringAn 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
rValidationResultThe validation result.
keystringThe key to associate the error with.
valuestringThe string to check.
messagestringAn optional error message.
Returns
- ValidationResult
The validation result.