Share via


ModelStateDictionaryExtensions.AddModelError Method

Definition

Overloads

AddModelError<TModel>(ModelStateDictionary, Expression<Func<TModel,Object>>, String)

Adds the specified errorMessage to the Errors instance that is associated with the specified expression. If the maximum number of allowed errors has already been recorded, ensures that a TooManyModelErrorsException exception is recorded instead.

AddModelError<TModel>(ModelStateDictionary, Expression<Func<TModel,Object>>, Exception, ModelMetadata)

Adds the specified exception to the Errors instance that is associated with the specified expression. If the maximum number of allowed errors has already been recorded, ensures that a TooManyModelErrorsException exception is recorded instead.

AddModelError<TModel>(ModelStateDictionary, Expression<Func<TModel,Object>>, String)

Source:
ModelStateDictionaryExtensions.cs
Source:
ModelStateDictionaryExtensions.cs
Source:
ModelStateDictionaryExtensions.cs

Adds the specified errorMessage to the Errors instance that is associated with the specified expression. If the maximum number of allowed errors has already been recorded, ensures that a TooManyModelErrorsException exception is recorded instead.

public:
generic <typename TModel>
[System::Runtime::CompilerServices::Extension]
 static void AddModelError(Microsoft::AspNetCore::Mvc::ModelBinding::ModelStateDictionary ^ modelState, System::Linq::Expressions::Expression<Func<TModel, System::Object ^> ^> ^ expression, System::String ^ errorMessage);
public static void AddModelError<TModel> (this Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary modelState, System.Linq.Expressions.Expression<Func<TModel,object>> expression, string errorMessage);
static member AddModelError : Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary * System.Linq.Expressions.Expression<Func<'Model, obj>> * string -> unit
<Extension()>
Public Sub AddModelError(Of TModel) (modelState As ModelStateDictionary, expression As Expression(Of Func(Of TModel, Object)), errorMessage As String)

Type Parameters

TModel

The type of the model.

Parameters

modelState
ModelStateDictionary

The ModelStateDictionary instance this method extends.

expression
Expression<Func<TModel,Object>>

An expression to be evaluated against an item in the current model.

errorMessage
String

The error message to add.

Applies to

AddModelError<TModel>(ModelStateDictionary, Expression<Func<TModel,Object>>, Exception, ModelMetadata)

Source:
ModelStateDictionaryExtensions.cs
Source:
ModelStateDictionaryExtensions.cs
Source:
ModelStateDictionaryExtensions.cs

Adds the specified exception to the Errors instance that is associated with the specified expression. If the maximum number of allowed errors has already been recorded, ensures that a TooManyModelErrorsException exception is recorded instead.

public:
generic <typename TModel>
[System::Runtime::CompilerServices::Extension]
 static void AddModelError(Microsoft::AspNetCore::Mvc::ModelBinding::ModelStateDictionary ^ modelState, System::Linq::Expressions::Expression<Func<TModel, System::Object ^> ^> ^ expression, Exception ^ exception, Microsoft::AspNetCore::Mvc::ModelBinding::ModelMetadata ^ metadata);
public static void AddModelError<TModel> (this Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary modelState, System.Linq.Expressions.Expression<Func<TModel,object>> expression, Exception exception, Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata metadata);
static member AddModelError : Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary * System.Linq.Expressions.Expression<Func<'Model, obj>> * Exception * Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata -> unit
<Extension()>
Public Sub AddModelError(Of TModel) (modelState As ModelStateDictionary, expression As Expression(Of Func(Of TModel, Object)), exception As Exception, metadata As ModelMetadata)

Type Parameters

TModel

The type of the model.

Parameters

modelState
ModelStateDictionary

The ModelStateDictionary instance this method extends.

expression
Expression<Func<TModel,Object>>

An expression to be evaluated against an item in the current model.

exception
Exception

The Exception to add.

metadata
ModelMetadata

The ModelMetadata associated with the model.

Applies to