Class ValidationService
Default implemetation of IValidationService.
Inheritance
Inherited Members
Namespace: EPiServer.Validation
Assembly: EPiServer.Framework.dll
Version: 9.12.2Syntax
[InitializableModule]
[ModuleDependency(typeof(ServiceContainerInitialization))]
public class ValidationService : IContextValidationService, IValidationService, IInitializableModule
Remarks
The implementation will scan for all implementaions of IValidate<T> and during validation call all instances where type parameter T can be assigned to from the instance that is to be validated.
Constructors
ValidationService()
Declaration
public ValidationService()
Properties
RegisteredValidators
Gets the registered validators.
Declaration
public IList<ValidatorWrapper> RegisteredValidators { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IList<ValidatorWrapper> | The registered validators. |
Remarks
The purpose of exposing registered validators is to make it possible to remove any unwanted validator. Note however that the underlying list is not thread safe so any changes to this list should be done from an initialization module.
Methods
Initialize(InitializationEngine)
Initializes this instance.
Declaration
public void Initialize(InitializationEngine context)
Parameters
Type | Name | Description |
---|---|---|
InitializationEngine | context | The initialization context. |
Remarks
Gets called as part of the EPiServer Framework initialization sequence. Note that it will be called only once per AppDomain, unless the method throws an exception. If an exception is thrown, the initialization method will be called repeatedly for each request reaching the site until the method succeeds.
Initialize(ITypeScannerLookup, IServiceLocator)
Initializes a new instance of the ValidationService class.
Declaration
public virtual void Initialize(ITypeScannerLookup typeScannerLookup, IServiceLocator serviceLocator)
Parameters
Type | Name | Description |
---|---|---|
ITypeScannerLookup | typeScannerLookup | The type scanner lookup. |
IServiceLocator | serviceLocator | The service locator. |
Uninitialize(InitializationEngine)
Resets the module into an uninitialized state.
Declaration
public void Uninitialize(InitializationEngine context)
Parameters
Type | Name | Description |
---|---|---|
InitializationEngine | context | The context. |
Remarks
This method is usually not called when running under a web application since the web app may be shut down very abruptly, but your module should still implement it properly since it will make integration and unit testing much simpler.
Any work done by Initialize(InitializationEngine) as well as any code executing on InitComplete should be reversed.
Validate(Object)
Validates the specified instance.
Declaration
public IEnumerable<ValidationError> Validate(object instance)
Parameters
Type | Name | Description |
---|---|---|
System.Object | instance | The instance. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ValidationError> |
Validate<T>(Object, T)
Declaration
public IEnumerable<ValidationError> Validate<T>(object instance, T context)
Parameters
Type | Name | Description |
---|---|---|
System.Object | instance | |
T | context |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ValidationError> |
Type Parameters
Name | Description |
---|---|
T |