Copied to clipboard

Flag this post as spam?

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


  • greengiant83 88 posts 109 karma points
    May 17, 2011 @ 22:37
    greengiant83
    0

    How to validate a document

    I have a document that I would like to validate as a whole before it is published. For instance one bit of validation I need to do is make sure one of the document's children has atleast one child under it.  The question is where can I inject my validation logic and be able to provide feedback to the user if there is a problem?

     

    I was thinking of hooking into the Document BeforePublish event and validating there, but there does not appear to be a way to provide feedback to the user if the publish needs to be cancelled.

     

    Then I was thinking about inserting a custom datatype into the Document's properties that would have a asp.net CustomValidator, because umbraco will run those and display the error messages, but then I dont see a way to get at the current document to be able to inspect it's properties. Also, I am not sure if those validators would be fired if you tried to set a future publish date.

     

    How can I enforce document validation and provide feedback to the user if there are problems?

  • greengiant83 88 posts 109 karma points
    May 19, 2011 @ 15:42
    greengiant83
    0

    The way I have I have settled on is to do the validation is by hooking into Document.BeforePublish and then creating a custom method for delivering any errors to the ui.  The hook into Document.BeforePublish seems like a good method but the error message delivery method is a bit of a hack since you have to get into umbraco's source code a bit.

Please Sign in or register to post replies

Write your reply to:

Draft