If I have following html method for rendering input box with custom attributes like:

public class SomeClass
{
    [Required]
    public int Minutes { get; set; }
}

public static MvcHtmlString ToolTipTextBox<TModel, TValue>(this HtmlHelper<TModel> helper, 
                Expression<Func<TModel, TValue>> expression, object htmlAttributes)
{
    ModelMetadata metaData = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
    ...
    bool isRequired = metaData.IsRequired ? true : false;
    string validationMessage = ???
}

Having metaData exposed for particular property how can I extract this message from data annotation attribute The Minutes field is required. to the validationMessage variable?

Related posts

Recent Viewed