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
rValidationResultThe validation result.
conditionboolThe condition to check.
messagestringThe 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
rValidationResultThe validation result.
keystringThe key to associate the error with.
conditionboolThe condition to check.
messagestringThe 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
rValidationResultThe validation result.
keystringThe key to associate the errors in the scope with.
valueIEnumerable<T>The collection to validate.
validateItemFunc<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
rValidationResultThe validation result.
keystringThe key to associate the errors in the scope with.
validateParameterFunc<ValidationResult, ValidationResult>A callback with nested error checks.
Returns
- ValidationResult
The validation result.