OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

ValidatingAsync & ValidatedAsync not raised during the content creation

Open hishamco opened this issue 3 months ago • 6 comments

What I notice is that when I create or publish content item(s), both ValidatingAsync & ValidatedAsync are not triggered, which is weird from the user perspective, because OC already did validate the fields

Why are these sorts of events called once you call ContentManager.ValidateAsync()? What if I want to intercept the content creation and do some validation?!!

I did a workaround by cancelling the process on publishing if the validation goes wrong

@Piedone @BenedekFarkas, is this by design while you are still managing some Orchard apps?

hishamco avatar Oct 17 '25 21:10 hishamco

No idea what the exact intent here was, but please formulate the problem and suggested fix in more detail. Also check out, there were discussions about this not long ago (not sure if issue, GitHub discussion, or Discord).

Piedone avatar Oct 17 '25 22:10 Piedone

  1. Create a ContentPartHander
  2. Override ValidatingAsync event
  3. Publish a content item that contains that part
  4. The event is not triggered

The expectation that the event should hits

hishamco avatar Oct 17 '25 22:10 hishamco

IDK, but O1 had (probably still has) similar issues where happy path testing didn't surface something that later seemed an obvious flaw/omission, e.g. https://github.com/OrchardCMS/Orchard/pull/8844/files#diff-32ba9042e7ffe517e3958c726eeca207d8591c7fa16ff763521eb60d6c7cec24R231-R237.

BenedekFarkas avatar Oct 18 '25 13:10 BenedekFarkas

but O1 had similar issues

Some things can't be evaluating at all times because they are too costly. This was a reason some validation was not applied for anything that happens on a content item. These events might just be triggered in UI related events.

sebastienros avatar Oct 23 '25 17:10 sebastienros

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

github-actions[bot] avatar Oct 23 '25 17:10 github-actions[bot]

IMHO, the simple approach is to call ContentManager.Validate() before publishing the content, if there's no objection I will submit a PR

hishamco avatar Oct 23 '25 17:10 hishamco