Esempio n. 1
0
        /// <summary>
        /// Get a definition of the validation on the current model.
        /// </summary>
        public static ModelLibraryValidationDefinition GetModelLibraryValidationDefinition(this HtmlHelper html)
        {
            var model = html?.ViewData?.Model;

            if (model == null)
            {
                return(new ModelLibraryValidationDefinition());
            }

            return(LibraryValidationDefinitionDefinitionUtils.GetModelLibraryValidationDefinition(model.GetType()));
        }
Esempio n. 2
0
        /// <summary>
        /// Get a definition of the validation on the current model.
        /// </summary>
        public static MvcHtmlString GetModelLibraryValidationDefinitionAsJson(this HtmlHelper html)
        {
            var model = html?.ViewData?.Model;
            ModelLibraryValidationDefinition definition;

            if (model == null)
            {
                definition = new ModelLibraryValidationDefinition();
            }
            else
            {
                definition = LibraryValidationDefinitionDefinitionUtils.GetModelLibraryValidationDefinition(model.GetType());
            }

            string json = SerializeJson(definition);

            return(new MvcHtmlString(json));
        }