Class ObjectValidationExtensions
- Namespace
- Admonish
- Assembly
- Admonish.dll
Contains object validation extension methods of ValidationResult.
public static class ObjectValidationExtensions
- Inheritance
-
ObjectValidationExtensions
- Inherited Members
Methods
Equal<T>(ValidationResult, string, T, T, string?)
Ensures that the specified object is equal to the expected one. When it is not equal, adds an error message to the ValidationResult and associates it with the specified key.
public static ValidationResult Equal<T>(this ValidationResult r, string key, T expected, T value, string? message = null)
Parameters
rValidationResultThe validation result.
keystringThe key to associate the error with.
expectedTThe expected value for the object.
valueTThe object to check.
messagestringAn optional error message.
Returns
- ValidationResult
The validation result.
Type Parameters
T
Remarks
It is recommended to specify a custom error message via
the message parameter, because the default one
contains neither the expected value nor the checked one.
NonNull<T>(ValidationResult, string, T?, string?)
Ensures that the specified object is not null. When it is, adds an error message to the ValidationResult and associates it with the specified key.
public static ValidationResult NonNull<T>(this ValidationResult r, string key, T? value, string? message = null) where T : struct
Parameters
rValidationResultThe validation result.
keystringThe key to associate the error with.
valueT?The object to check.
messagestringAn optional error message.
Returns
- ValidationResult
The validation result.
Type Parameters
T
NonNull<T>(ValidationResult, string, T?, string?)
Ensures that the specified object is not null. When it is, adds an error message to the ValidationResult and associates it with the specified key.
public static ValidationResult NonNull<T>(this ValidationResult r, string key, T? value, string? message = null) where T : class
Parameters
rValidationResultThe validation result.
keystringThe key to associate the error with.
valueTThe object to check.
messagestringAn optional error message.
Returns
- ValidationResult
The validation result.
Type Parameters
T
NotEqual<T>(ValidationResult, string, T, T, string?)
Ensures that the specified object is not equal to the forbidden one. When it is equal, adds an error message to the ValidationResult and associates it with the specified key.
public static ValidationResult NotEqual<T>(this ValidationResult r, string key, T forbidden, T value, string? message = null)
Parameters
rValidationResultThe validation result.
keystringThe key to associate the error with.
forbiddenTThe forbidden value for the object.
valueTThe object to check.
messagestringAn optional error message.
Returns
- ValidationResult
The validation result.
Type Parameters
T
Remarks
It is recommended to specify a custom error message via
the message parameter, because the default one
does not contain the forbidden value.
Null<T>(ValidationResult, string, T?, string?)
Ensures that the specified object is null. When it is not, adds an error message to the ValidationResult and associates it with the specified key.
public static ValidationResult Null<T>(this ValidationResult r, string key, T? value, string? message = null) where T : struct
Parameters
rValidationResultThe validation result.
keystringThe key to associate the error with.
valueT?The object to check.
messagestringAn optional error message.
Returns
- ValidationResult
The validation result.
Type Parameters
T
Null<T>(ValidationResult, string, T?, string?)
Ensures that the specified object is null. When it is not, adds an error message to the ValidationResult and associates it with the specified key.
public static ValidationResult Null<T>(this ValidationResult r, string key, T? value, string? message = null) where T : class
Parameters
rValidationResultThe validation result.
keystringThe key to associate the error with.
valueTThe object to check.
messagestringAn optional error message.
Returns
- ValidationResult
The validation result.
Type Parameters
T