Skip to main content

FluentValidationModelValidatorProvider

Implementation of ModelValidatorProvider that uses FluentValidation.

Assembly: ServiceStack.Mvc.dll
View Source
Declaration
public class FluentValidationModelValidatorProvider : ModelValidatorProvider

Properties

AddImplicitRequiredValidator

View Source
Declaration
public bool AddImplicitRequiredValidator { get; set; }

ValidatorFactory

View Source
Declaration
public IValidatorFactory ValidatorFactory { get; set; }

Methods

Configure(Action<FluentValidationModelValidatorProvider>)

Initializes the FluentValidationModelValidatorProvider using the default options and adds it in to the ModelValidatorProviders collection.

View Source
Declaration
public static void Configure(Action<FluentValidationModelValidatorProvider> configurationExpression = null)
Parameters
TypeName
System.Action<ServiceStack.FluentValidation.Mvc.FluentValidationModelValidatorProvider>configurationExpression

Add(Type, FluentValidationModelValidationFactory)

View Source
Declaration
public void Add(Type validatorType, FluentValidationModelValidationFactory factory)
Parameters
TypeName
System.TypevalidatorType
ServiceStack.FluentValidation.Mvc.FluentValidationModelValidationFactoryfactory

GetValidators(ModelMetadata, ControllerContext)

View Source
Declaration
public override IEnumerable<ModelValidator> GetValidators(ModelMetadata metadata, ControllerContext context)
Returns

System.Collections.Generic.IEnumerable<ModelValidator>

Parameters
TypeName
ModelMetadatametadata
ControllerContextcontext

CreateValidator(ModelMetadata, ControllerContext)

View Source
Declaration
protected virtual IValidator CreateValidator(ModelMetadata metadata, ControllerContext context)
Returns

ServiceStack.FluentValidation.IValidator

Parameters
TypeName
ModelMetadatametadata
ControllerContextcontext

GetValidatorsForProperty(ModelMetadata, ControllerContext, IValidator)

View Source
Declaration
protected IEnumerable<ModelValidator> GetValidatorsForProperty(ModelMetadata metadata, ControllerContext context, IValidator validator)
Returns

System.Collections.Generic.IEnumerable<ModelValidator>

Parameters
TypeName
ModelMetadatametadata
ControllerContextcontext
ServiceStack.FluentValidation.IValidatorvalidator

GetModelValidator(ModelMetadata, ControllerContext, PropertyRule, IPropertyValidator)

View Source
Declaration
protected virtual ModelValidator GetModelValidator(ModelMetadata meta, ControllerContext context, PropertyRule rule, IPropertyValidator propertyValidator)
Returns

ModelValidator

Parameters
TypeName
ModelMetadatameta
ControllerContextcontext
ServiceStack.FluentValidation.Internal.PropertyRulerule
ServiceStack.FluentValidation.Validators.IPropertyValidatorpropertyValidator

CreateNotNullValidatorForProperty(ModelMetadata, ControllerContext)

View Source
Declaration
protected virtual ModelValidator CreateNotNullValidatorForProperty(ModelMetadata metadata, ControllerContext cc)
Returns

ModelValidator

Parameters
TypeName
ModelMetadatametadata
ControllerContextcc

GetValidatorsForModel(ModelMetadata, ControllerContext, IValidator)

View Source
Declaration
protected virtual IEnumerable<ModelValidator> GetValidatorsForModel(ModelMetadata metadata, ControllerContext context, IValidator validator)
Returns

System.Collections.Generic.IEnumerable<ModelValidator>

Parameters
TypeName
ModelMetadatametadata
ControllerContextcontext
ServiceStack.FluentValidation.IValidatorvalidator

IsValidatingProperty(ModelMetadata)

View Source
Declaration
protected virtual bool IsValidatingProperty(ModelMetadata metadata)
Returns

System.Boolean

Parameters
TypeName
ModelMetadatametadata