Class ValidationBuilder<T>
Provides an advanced builder for validating complex objects with multiple properties.
Inherited Members
Namespace: ValidationFramework
Assembly: ValidationFramework.dll
Syntax
public class ValidationBuilder<T> where T : class
Type Parameters
| Name | Description |
|---|---|
| T | The type of object to validate. |
Methods
| Edit this page View SourceAddValidation(string, Func<T, ValidationResult>)
Adds a validation function for a specific property.
Declaration
public ValidationBuilder<T> AddValidation(string propertyName, Func<T, ValidationResult> validation)
Parameters
| Type | Name | Description |
|---|---|---|
| string | propertyName | The name of the property to validate. |
| Func<T, ValidationResult> | validation | The validation function to apply to the property. |
Returns
| Type | Description |
|---|---|
| ValidationBuilder<T> | This builder instance for method chaining. |
Validate(T)
Validates the specified entity against all registered property validations.
Declaration
public ValidationResult Validate(T entity)
Parameters
| Type | Name | Description |
|---|---|---|
| T | entity | The entity to validate. |
Returns
| Type | Description |
|---|---|
| ValidationResult | A ValidationResult containing all validation errors. |