C# Class Rebel.Cms.Web.ModelStateExtensions

Mostra file Open project: RebelCMS/rebelcmsxu5

Public Methods

Method Description
AddDataValidationError ( this state, string errorMessage ) : void

Adds an error to the model state that has to do with data validation, this is generally used for JSON responses

IsValid ( this state, string prefix ) : bool

Checks if there are any model errors on any fields containing the prefix

Merge ( this state, ModelStateDictionary dictionary, string prefix ) : void

Merges ModelState that has names matching the prefix

ToJsonErrors ( this state ) : System.Web.Mvc.JsonResult

Serializes the ModelState to JSON for JavaScript to interrogate the errors

Method Details

AddDataValidationError() public static method

Adds an error to the model state that has to do with data validation, this is generally used for JSON responses
public static AddDataValidationError ( this state, string errorMessage ) : void
state this
errorMessage string
return void

IsValid() public static method

Checks if there are any model errors on any fields containing the prefix
public static IsValid ( this state, string prefix ) : bool
state this
prefix string
return bool

Merge() public static method

Merges ModelState that has names matching the prefix
public static Merge ( this state, ModelStateDictionary dictionary, string prefix ) : void
state this
dictionary ModelStateDictionary
prefix string
return void

ToJsonErrors() public static method

Serializes the ModelState to JSON for JavaScript to interrogate the errors
public static ToJsonErrors ( this state ) : System.Web.Mvc.JsonResult
state this
return System.Web.Mvc.JsonResult