DataAnnotationsClientModelValidator<TAttribute> Class

Summary

An implementation of [Microsoft.AspNet.Mvc.ModelBinding.Validation.IClientModelValidator]() which understands data annotation attributes.

Inheritance Hierarchy

  • System.Object
  • Microsoft.AspNet.Mvc.ModelBinding.Validation.DataAnnotationsClientModelValidator<TAttribute>

Syntax

public abstract class DataAnnotationsClientModelValidator<TAttribute> : IClientModelValidator where TAttribute : ValidationAttribute

GitHub

View on GitHub

Microsoft.AspNet.Mvc.ModelBinding.Validation.DataAnnotationsClientModelValidator<TAttribute>

Constructors

DataAnnotationsClientModelValidator(TAttribute)

Create a new instance of [Microsoft.AspNet.Mvc.ModelBinding.Validation.DataAnnotationsClientModelValidator`1](Microsoft.AspNet.Mvc.ModelBinding.Validation.DataAnnotationsClientModelValidator`1.yml).

Arguments:
  • attribute (TAttribute) – The <typeparamref name=”TAttribute” /> instance to validate.
public DataAnnotationsClientModelValidator(TAttribute attribute)

Properties

Attribute()

Gets the <typeparamref name=”TAttribute” /> instance.

Return type:TAttribute
public TAttribute Attribute { get; }

Methods

GetClientValidationRules(Microsoft.AspNet.Mvc.ModelBinding.Validation.ClientModelValidationContext)
Arguments:
Return type:

System.Collections.Generic.IEnumerable{Microsoft.AspNet.Mvc.ModelBinding.Validation.ModelClientValidationRule}

public abstract IEnumerable<ModelClientValidationRule> GetClientValidationRules(ClientModelValidationContext context)
GetErrorMessage(Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata)

Gets the error message formatted using the [Microsoft.AspNet.Mvc.ModelBinding.Validation.DataAnnotationsClientModelValidator`1.Attribute](Microsoft.AspNet.Mvc.ModelBinding.Validation.DataAnnotationsClientModelValidator`1.yml).

Arguments:
  • modelMetadata (Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata) – The [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata]() associated with the model annotated with [Microsoft.AspNet.Mvc.ModelBinding.Validation.DataAnnotationsClientModelValidator`1.Attribute](Microsoft.AspNet.Mvc.ModelBinding.Validation.DataAnnotationsClientModelValidator`1.yml).
Return type:

System.String

Returns:

Formatted error string.

protected virtual string GetErrorMessage(ModelMetadata modelMetadata)