Class Extensions
A static class containing extension methods for validating objects that implement the IValidatableObject interface.
Inherited Members
Namespace: Innovt.Core.Validation
Assembly: Innovt.Core.dll
Syntax
public static class Extensions
Methods
| Edit this page View SourceEnsureIsValid(ICommand, ValidationContext)
Ensures that a command object is valid by treating it as an IValidatableObject; otherwise, throws a BusinessException with validation errors.
Declaration
public static void EnsureIsValid(this ICommand command, ValidationContext context = null)
Parameters
Type | Name | Description |
---|---|---|
ICommand | command | The command to validate. |
ValidationContext | context | An optional ValidationContext to specify validation context. |
EnsureIsValid(ICommand, string)
Ensures that a command object is valid by treating it as an IValidatableObject; otherwise, throws a BusinessException with validation errors.
Declaration
public static void EnsureIsValid(this ICommand command, string contextName)
Parameters
Type | Name | Description |
---|---|---|
ICommand | command | The command to validate. |
string | contextName | The name of the validation context. |
EnsureIsValid(IValidatableObject, ValidationContext)
Ensures that an object implementing the IValidatableObject interface is valid; otherwise, throws a BusinessException with validation errors.
Declaration
public static void EnsureIsValid(this IValidatableObject obj, ValidationContext context = null)
Parameters
Type | Name | Description |
---|---|---|
IValidatableObject | obj | The object to validate. |
ValidationContext | context | An optional ValidationContext to specify validation context. |
IsValid(IValidatableObject, ValidationContext)
Checks whether an object implementing the IValidatableObject interface is valid.
Declaration
public static bool IsValid(this IValidatableObject obj, ValidationContext context = null)
Parameters
Type | Name | Description |
---|---|---|
IValidatableObject | obj | The object to validate. |
ValidationContext | context | An optional ValidationContext to specify validation context. |
Returns
Type | Description |
---|---|
bool | True if the object is valid; otherwise, false. |
Validate(IEnumerable<IValidatableObject>, ValidationContext)
Validates a collection of objects implementing the IValidatableObject interface and returns a collection of ValidationResult objects.
Declaration
public static IEnumerable<ValidationResult> Validate(this IEnumerable<IValidatableObject> array, ValidationContext context = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<IValidatableObject> | array | The collection of objects to validate. |
ValidationContext | context | An optional ValidationContext to specify validation context. |
Returns
Type | Description |
---|---|
IEnumerable<ValidationResult> | A collection of ValidationResult objects containing validation errors. |