Documentation > CMS Template API Library > PostInputContext > ValidationError
ValidationError
Setting this causes the input form to be redisplayed with this message at the top.
Type
System.String
Code Example
C#
Sample:
if (!context.InputForm.HasField("title")) // If a title is not provided
{
// redisplay the input form with this message
context.ValidationError = "Please add a title.";
}
else if (!asset.Label.Equals(context.InputForm["title"])) // If value is different from current label
{
asset.Rename(context.InputForm["title"]); // rename asset to new title value.
}