Try our conversational search powered by Generative AI!

Shared blocks and validation attributes in EPiServer 11


We're having some issues with validation of properties on shared blocks in EPiServer 11.

Custom attribute:

public class ValidYoutubeLink : ValidationAttribute
    protected override ValidationResult IsValid(object value, ValidationContext validationContext)

Shared block:

[ContentType(GUID = "...")]
public class YoutubeBlock : BlockData
    public virtual string VideoUrl { get; set; }

As an editor, I try to create a new shared block inside For All Sites folder.

In theory, Episerver should validate all the properties before executing EPiServer.DataFactory.Save()

But in practice, I can enter invalid values, click the Save button and go to next screen!

On the next screen, I'm able to click the Publish button. However, nothing happens when I do that. No validation errors in the edit mode, no meaningful errors in dev. tools console, nothing!

Apr 06, 2018 17:47

Just out of curiosity - is validation interface working properly for shared blocks?

Apr 09, 2018 5:51

I tried with the IValidate interface as well.

Validate method does not get executed on the first screen where editors have to enter required properties.

It only works on the second screen, when the block is already created and auto-saved.

Apr 09, 2018 10:17

The support team has verified the bug.

Apr 11, 2018 13:21

Here's another one:

I have a page which has a local block that is decorated with a custom ValidationAttribute.

In edit mode, when I try to publish the page with invalid values, IsValid() method gets executed, and I see validation errors in edit mode. That's fine.

But when I correct the validation errors and try to publish the page again, the Publish button is no longer visible.


Edited, May 03, 2018 12:05
* 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.