Class ValidatorFactory
A service which gets a validator from any of a number of mechanisms.
Inheritance
Implements
Inherited Members
Namespace: CSF.Validation
Assembly: CSF.Validation.dll
Syntax
public class ValidatorFactory : IGetsValidator
Constructors
| Improve this Doc View SourceValidatorFactory(IServiceProvider)
Initialises a new instance of ValidatorFactory.
Declaration
public ValidatorFactory(IServiceProvider serviceProvider)
Parameters
Type | Name | Description |
---|---|---|
System.IServiceProvider | serviceProvider | A service provider. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If the |
Methods
| Improve this Doc View SourceGetValidator(ValidationManifest)
Gets a validator instance using a specified validation manifest. A validation manifest is a model which may specify a validator using data.
Declaration
public IValidator GetValidator(ValidationManifest manifest)
Parameters
Type | Name | Description |
---|---|---|
ValidationManifest | manifest | The validation manifest. |
Returns
Type | Description |
---|---|
IValidator | A validator implementation. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If the |
ValidatorBuildingException | If the |
GetValidator(Value, Type)
Gets a validator instance using a specified validation manifest. A validation manifest is a model which may specify a validator using data. This overload uses a simplified/serialization-friendly model.
Declaration
public IValidator GetValidator(Value manifestModel, Type validatedType)
Parameters
Type | Name | Description |
---|---|---|
Value | manifestModel | A simplified validation manifest model. |
System.Type | validatedType | The type of object to be validated. |
Returns
Type | Description |
---|---|
IValidator | A validator implementation. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If the |
ValidatorBuildingException | If the |
GetValidator(Type)
Gets a validator instance using a specified builder type which specifies a validator via code.
Declaration
public IValidator GetValidator(Type builderType)
Parameters
Type | Name | Description |
---|---|---|
System.Type | builderType | The type of a class which implements IBuildsValidator<TValidated> for the desired validated type. |
Returns
Type | Description |
---|---|
IValidator | A validator implementation. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If the |
System.ArgumentException | If the |
GetValidator<TValidated>(IBuildsValidator<TValidated>)
Gets a validator instance using a specified validator-builder instance which specifies a validator via code.
Declaration
public IValidator<TValidated> GetValidator<TValidated>(IBuildsValidator<TValidated> builder)
Parameters
Type | Name | Description |
---|---|---|
IBuildsValidator<TValidated> | builder | An instance of a validator-builder. |
Returns
Type | Description |
---|---|
IValidator<TValidated> | A strongly-typed validator implementation. |
Type Parameters
Name | Description |
---|---|
TValidated | The type of object to be validated. |