Table of Contents

Class DefaultBodyModelValidator

Namespace
System.Web.Http.Validation
Assembly
System.Web.Http.dll

Represents a class used to recursively validate an object.

public class DefaultBodyModelValidator : IBodyModelValidator
Inheritance
DefaultBodyModelValidator
Implements
Inherited Members

Constructors

DefaultBodyModelValidator()

Initializes a new instance of the DefaultBodyModelValidator class.

public DefaultBodyModelValidator()

Methods

ShallowValidate(ModelMetadata, BodyModelValidatorContext, object, IEnumerable<ModelValidator>)

protected virtual bool ShallowValidate(ModelMetadata metadata, BodyModelValidatorContext validationContext, object container, IEnumerable<ModelValidator> validators)

Parameters

metadata ModelMetadata
validationContext BodyModelValidatorContext
container object
validators IEnumerable<ModelValidator>

Returns

bool

ShouldValidateType(Type)

Determines whether instances of a particular type should be validated.

public virtual bool ShouldValidateType(Type type)

Parameters

type Type

The type to validate.

Returns

bool

true if the type should be validated; false otherwise.

Validate(object, Type, ModelMetadataProvider, HttpActionContext, string)

Determines whether the model is valid and adds any validation errors to the actionContext's ModelStateDictionary.

public bool Validate(object model, Type type, ModelMetadataProvider metadataProvider, HttpActionContext actionContext, string keyPrefix)

Parameters

model object

The model to be validated.

type Type

The Type to use for validation.

metadataProvider ModelMetadataProvider

The ModelMetadataProvider used to provide model metadata.

actionContext HttpActionContext

The HttpActionContext within which the model is being validated.

keyPrefix string

The string to append to the key for any validation errors.

Returns

bool

true if model is valid, false otherwise.

ValidateElements(IEnumerable, BodyModelValidatorContext)

protected virtual bool ValidateElements(IEnumerable model, BodyModelValidatorContext validationContext)

Parameters

model IEnumerable
validationContext BodyModelValidatorContext

Returns

bool

ValidateNodeAndChildren(ModelMetadata, BodyModelValidatorContext, object, IEnumerable<ModelValidator>)

protected virtual bool ValidateNodeAndChildren(ModelMetadata metadata, BodyModelValidatorContext validationContext, object container, IEnumerable<ModelValidator> validators)

Parameters

metadata ModelMetadata
validationContext BodyModelValidatorContext
container object
validators IEnumerable<ModelValidator>

Returns

bool

ValidateProperties(ModelMetadata, BodyModelValidatorContext)

protected virtual bool ValidateProperties(ModelMetadata metadata, BodyModelValidatorContext validationContext)

Parameters

metadata ModelMetadata
validationContext BodyModelValidatorContext

Returns

bool