How to display a list of validation messages?

Vote:
 

Hi 

I am trying to pass a list of error messages to CancelReason property of ConventEvent class, and display each message in its own

  • , but I can't figure out how to achieve this.
  • https://www.dropbox.com/s/g0aft1mh5dkyc39/2016-03-22_11-30-38.png?dl=0

    Anyone has a solution for this?

    Thanks,

    Vincent

    #146719
    Mar 22, 2016 4:32
    Vote:
     

    Implement multiple validators? :)

    #146728
    Mar 22, 2016 9:20
    Vote:
     

    Hi Daniel

    Thanks for your reply. 

    How multiple validators could be used to fix this problem? The CancelReason only accepts a string value

    Can you provide a code sample?

    #146731
    Mar 22, 2016 10:40
    Vote:
     

    Hello Vincent

    You could consider considering implementing an IValidator<T> interface rather than use the content events. This allows you to return a collection of messages. See http://www.david-tec.com/2012/06/EPiServer-7-Preview---IValidator-interface/

    David

    #146743
    Mar 22, 2016 12:49
    Vote:
     

    I meant using validators like David also suggested. How many depends on your view on single responsibility principle :)

    Haven't tried to use multiple validators myself on the same content type though. My validation is pretty small so no need to split it up. But in theory you could validate vs an interface like IHasSeoInformation or similar.

    #146758
    Edited, Mar 22, 2016 17:22
    * You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.