ModelStateDictionary.AddModelError ModelStateDictionary.AddModelError ModelStateDictionary.AddModelError ModelStateDictionary.AddModelError Method

Definition

Overloads

AddModelError(String, String) AddModelError(String, String) AddModelError(String, String) AddModelError(String, String)

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

AddModelError(String, Exception, ModelMetadata) AddModelError(String, Exception, ModelMetadata) AddModelError(String, Exception, ModelMetadata)

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

AddModelError(String, String) AddModelError(String, String) AddModelError(String, String) AddModelError(String, String)

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

public:
 void AddModelError(System::String ^ key, System::String ^ errorMessage);
public void AddModelError (string key, string errorMessage);
member this.AddModelError : string * string -> unit
Public Sub AddModelError (key As String, errorMessage As String)

Parameters

key
String String String String

The key of the ModelStateEntry to add errors to.

errorMessage
String String String String

The error message to add.

AddModelError(String, Exception, ModelMetadata) AddModelError(String, Exception, ModelMetadata) AddModelError(String, Exception, ModelMetadata)

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

public:
 void AddModelError(System::String ^ key, Exception ^ exception, Microsoft::AspNetCore::Mvc::ModelBinding::ModelMetadata ^ metadata);
public void AddModelError (string key, Exception exception, Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata metadata);
member this.AddModelError : string * Exception * Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata -> unit

Parameters

key
String String String String

The key of the ModelStateEntry to add errors to.

exception
Exception Exception Exception Exception

The Exception to add. Some exception types will be replaced with a descriptive error message.

metadata
ModelMetadata ModelMetadata ModelMetadata ModelMetadata

The ModelMetadata associated with the model.

Applies to