Class ValidationExtensions
- Namespace
- Admonish
- Assembly
- Admonish.dll
Contains convenience methods for ValidationResult.
public static class ValidationExtensions
- Inheritance
-
ValidationExtensions
- Inherited Members
Methods
Check(ValidationResult, bool, string)
Ensures that the specified condition is true. When it is false, adds the specified error message to the ValidationResult.
public static ValidationResult Check(this ValidationResult r, bool condition, string message)
Parameters
r
ValidationResultThe validation result.
condition
boolThe condition to check.
message
stringThe error message.
Returns
- ValidationResult
The validation result.
Check(ValidationResult, string, bool, string)
Ensures that the specified condition is true. When it is false, adds the specified error message to the ValidationResult and associates it with the specified key.
public static ValidationResult Check(this ValidationResult r, string key, bool condition, string message)
Parameters
r
ValidationResultThe validation result.
key
stringThe key to associate the error with.
condition
boolThe condition to check.
message
stringThe error message.
Returns
- ValidationResult
The validation result.
Collection<T>(ValidationResult, string, IEnumerable<T>, Func<ValidationResult, T, ValidationResult>)
Begins a scope in which a collection is validated and errors are associated with the specified key.
public static ValidationResult Collection<T>(this ValidationResult r, string key, IEnumerable<T> value, Func<ValidationResult, T, ValidationResult> validateItem)
Parameters
r
ValidationResultThe validation result.
key
stringThe key to associate the errors in the scope with.
value
IEnumerable<T>The collection to validate.
validateItem
Func<ValidationResult, T, ValidationResult>A callback validating a single item.
Returns
- ValidationResult
The validation result.
Type Parameters
T
WithKey(ValidationResult, string, Func<ValidationResult, ValidationResult>)
Begins a scope in which all errors are associated with the specified key.
public static ValidationResult WithKey(this ValidationResult r, string key, Func<ValidationResult, ValidationResult> validateParameter)
Parameters
r
ValidationResultThe validation result.
key
stringThe key to associate the errors in the scope with.
validateParameter
Func<ValidationResult, ValidationResult>A callback with nested error checks.
Returns
- ValidationResult
The validation result.