Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • pranjal 75 posts 188 karma points
    Apr 26, 2018 @ 08:11
    pranjal
    0

    Umbraco Document Type Name Validation

    I want to add validation to a document type in Umbraco in back office when user create any document i want that document name should take minimum 10 characters only

    How to do that ????? Please refer highlighted area in screenshot- i want my validation on this name.

    enter image description here

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 26, 2018 @ 08:33
    Michaël Vanbrabandt
    100

    Hi pranjal,

    you can hook into the events of the ContentType:

    https://our.umbraco.org/documentation/reference/events/ContentTypeService-Events

    The one you should use is the SavingContentType where you then can do your checks.

    Code example:

    public class YourCustomEvents: ApplicationEventHandler
    {
        // Fired when application is started
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {       
            ContentTypeService.SavingContentType += ContentTypeService_SavingContentType;
        }
    
        private void ContentTypeService_SavingContentType(IContentTypeService sender, Umbraco.Core.Events.SaveEventArgs<Umbraco.Core.Models.IContentType> e)
        {
            // Do your checks
        }
    }
    

    Hope this helps!

    /Michaël

Please Sign in or register to post replies

Write your reply to:

Draft