Validation on onPublish of document

Hello, I need to add a validation on document on click of “publish”(not on save).
I am trying to implement it through documentworkflow(scxml). I am able to add VlidationAction class but not able to show specific error messages on document.
Can you please provide some details on this?

I am trying to implement below approach.

“One way is through the use of a Workflow, which is a series of steps that content goes through before it is published. Workflows can be configured to include validation steps that check the content for compliance with specific standards or guidelines, such as branding guidelines, legal requirements, or accessibility standards.”

Thanks

I believe when you save the validation is called by the editor plugin, which can display validation messages because it is a UI plugin. When you change the scxml you aren’t in a place that is part of the ui. You’d have to change the behavior of the publish button on the menu.

Hello Jasper,

Thank you for the clarification, Can you please share some details on how can I have the same feature to add a validator class which is right now only for save button to be available for Publish as well? Because that has proper validation feature.

Thanks

Hello Yod,

I would challenge the approach you have taken as it sounds quite complicated. What kind of validation are you trying to achieve on the document?

Because in order to publish, your document has to go through the save/done process when the normal validation procedure takes place and you can inject your custom validation as described here.

HTH

Hi Lef,

Thank you for the response, I know its been long and I tried to keep the validation on Save and done but now it seems that will not work.
Requirement for this validation is to not restrict users to save the contents but not
to allow them to publish unless they have filled some mandatory fields.

With Save and Done if we make fields mandatory , Editors are not even able to save the document with other details which they have at the moment.

Thank you.

If you don’t wan to fill in required fields, you can always use “Save as draft” and your changes will be persisted.

Main difference between “Save as draft” and “Save and done” is that you can’t preview draft documents, but that makes sense, because most frontends I have seen implemented will just break (rarely developers add additional checks for things that they expect to be there at all time)