RangeAttribute.FormatErrorMessage(String) 方法

定義

格式化在範圍驗證失敗時所顯示的錯誤訊息。Formats the error message that is displayed when range validation fails.

public:
 override System::String ^ FormatErrorMessage(System::String ^ name);
public override string FormatErrorMessage (string name);
override this.FormatErrorMessage : string -> string
Public Overrides Function FormatErrorMessage (name As String) As String

參數

name
String

造成錯誤失敗之欄位的名稱。The name of the field that caused the validation failure.

傳回

String

格式化的錯誤訊息。The formatted error message.

例外狀況

目前的屬性格式不正確。The current attribute is ill-formed.

備註

FormatErrorMessage會使用導致驗證失敗的資料欄位名稱建立錯誤訊息。The FormatErrorMessage creates the error message by using the name of the data field that caused the validation failure. 您可以在自訂驗證屬性中覆寫這個方法,以自訂錯誤的建立方式,或提供更複雜的訊息,其中包含您在執行時間評估的參數。You can override this method in a custom validation attribute to customize how errors are created, or to provide a more complex message that contains parameters that you evaluate at run time. 如需範例,請參閱 RangeAttribute.RangeAttributeFor an example, see the RangeAttribute.RangeAttribute constructor.

適用於