Class ValidationRule<T>
Represents a single validation rule with a condition and error message.
Inherited Members
Namespace: ValidationFramework
Assembly: ValidationFramework.dll
Syntax
public class ValidationRule<T>
Type Parameters
| Name | Description |
|---|---|
| T | The type of value to validate. |
Constructors
| Edit this page View SourceValidationRule(Func<T, bool>, string)
Initializes a new instance of the ValidationRule<T> class.
Declaration
public ValidationRule(Func<T, bool> rule, string errorMessage)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<T, bool> | rule | The function that defines the validation condition. |
| string | errorMessage | The error message to return if validation fails. |
Methods
| Edit this page View SourceValidate(T)
Validates the specified value against this rule.
Declaration
public (bool isValid, string error) Validate(T value)
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | The value to validate. |
Returns
| Type | Description |
|---|---|
| (bool isValid, string error) | A tuple containing the validation result and error message. |