November Happy Hour will be moved to Thursday December 5th.

IValidate breaks dojo

Vote:
 
public class MyBlockValidator : IValidate<MyBlock>
	{
		public IEnumerable<ValidationError> Validate(MyBlock instance)
		{
			if (instance.ImageContainer?.Image != null && (!string.IsNullOrEmpty(instance.VideoUrl) || instance.Screen9Video != null))
			{
				yield return new ValidationError
				{
					ErrorMessage = LocalizationService.Current.GetString(Global.LocalizationStringKeys.Validation.VideoAndImageNotAllowed),
					Severity = ValidationErrorSeverity.Error,
					ValidationType = ValidationErrorType.Unspecified,
					PropertyName = nameof(MyBlock.ImageContainer),
					RelatedProperties = new[] { nameof(MyBlock.VideoUrl), nameof(MyBlock.Screen9Video) }
				};
			}

			if ((instance.Screen9Video != null || !string.IsNullOrEmpty(instance.VideoUrl)) && string.IsNullOrWhiteSpace(instance.VideoTitle))
			{
				yield return new ValidationError
				{
					ErrorMessage = LocalizationService.Current.GetString(Global.LocalizationStringKeys.Validation.VideoTitleMissing),
					Severity = ValidationErrorSeverity.Error,
					ValidationType = ValidationErrorType.Unspecified,
					PropertyName = nameof(MyBlock.VideoTitle),
					RelatedProperties = new[] { nameof(MyBlock.VideoUrl), nameof(MyBlock.Screen9Video) }
				};
			}

			yield break;
		}
	}

Having implemented validation on a block works when editing an existing block but breaks on new block

Dojo gets status 409 "The page was not displayed because there was a conflict"

Any ideas on why?

#271542
Feb 11, 2022 13:35
Vote:
 

Hi Jonas,

I believe this was reported as a bug previously Bug - CMS-11522 (optimizely.com)

However I see you are on a later version.

There is also a support document that describe similar behaviour are these useful 409 conflict Creating page/block – Support Help Center (optimizely.com)?

Paul

#271708
Feb 14, 2022 17:29
Vote:
 

Hi Jonas

To further build upon Paul answer, one soloution is to only change the behavior for request when in editmode like this.

<location path="Path/to/your/editAdmin">
    <system.webServer>
      
      <httpErrors errorMode="DetailedLocalOnly" existingResponse="Auto" />
    </system.webServer>
</location>

#277318
Mar 28, 2022 3:41
Jonas Boman - Dec 22, 2022 13:28
Sorry for late response, but this certainly was the issue! Thanks
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.