Shared blocks and validation attributes in EPiServer 11

Vote:
 

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

Custom attribute:

[AttributeUsage(AttributeTargets.Property)]
public class ValidYoutubeLink : ValidationAttribute
{
    protected override ValidationResult IsValid(object value, ValidationContext validationContext)
    {
        ...
    }
}

Shared block:

[ContentType(GUID = "...")]
public class YoutubeBlock : BlockData
{
    [Display(...)]
    [Required]
    [ValidYoutubeLink]
    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() 

https://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/7/Validation/Validation/

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!

#190281
Apr 06, 2018 17:47
Vote:
 

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

#190295
Apr 09, 2018 5:51
Vote:
 

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.

#190315
Apr 09, 2018 10:17
Vote:
 

The support team has verified the bug.
CMS-10294

#190499
Apr 11, 2018 13:21
Vote:
 

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.

CMS-10475

#191970
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.