tom
September 30, 2021, 8:19am
1
Add contentLib.validate(content)
Is it possible to expose the validation that is being run on contentLib.modify()
, so that it can be run independently?
It can be useful when creating some tooling around updating content when modifying content-type xmls.
bhj
September 30, 2021, 12:35pm
2
Wasn’t this in the content roadmap before? Now I can’t find it anymore.
I’m talking about this:
Checklist support on content API - custom tailored scripts that can validate content before being allowed for publishing.
Source: Highlights from PAB - September 2018
rymsha
September 30, 2021, 5:02pm
3
In XP 7.8 we plan to introduce a Content Validation API.
The good news - this work is mostly done.
The bad news - for now, only Java API will be available.
1 Like
tsi
October 6, 2021, 7:44am
4
I guess one would have to submit a complete “new” content document, in order for this to work. Also, there is the problem of attachments - which are uploaded asyncronously - and can be validated themself.
Are you aware of the “requirevalid” option when creating or modifying content with the current API? So, by setting requireValid=true, a new document or change will not be persisted. IMHO this seems to solve your requirement?
tom
October 6, 2021, 9:16am
5
tsi:
Are you aware of the “requirevalid” option when creating or modifying content with the current API? So, by setting requireValid=true, a new document or change will not be persisted. IMHO this seems to solve your requirement?
I’m familiar with requireValid
.
Part of my thought here is that I wouldn’t want get updates my version log unnecessary.
Some usecases
Create an admin-tool that gives content creators a list of invalid content that they have to open and fix.
I have some code that will migrate my content to match changes in the content-type-xml, and I want to perform a “dry run” before updating the data.
rymsha
October 12, 2021, 6:55am
6
Upcoming validation API won’t solve your case directly.
Yet with some Java/OSGi knowledge it will be possible.
Receiving all the validators:
private final List<ContentValidator> contentValidators = new CopyOnWriteArrayList<>();
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
public void addContentValidator( final ContentValidator contentValidator )
{
this.contentValidators.add( contentValidator );
}
public void removeContentValidator( final ContentValidator contentValidator )
{
this.contentValidators.remove( contentValidator );
}
And then using them:
for ( ContentValidator contentValidator : contentValidators )
{
if ( contentValidator.supports( contentTypeName ) )
{
contentValidator.validate( validatorParams, resultBuilder );
}
}
So we are getting closer to implement it as JS API at some point. Unfortunately not in XP 7.8
1 Like
tom
October 12, 2021, 7:06am
7
Awesome! It’s not something I needed right now anyway.
I just had some ideas where I could use it, so I just wanted to put it on Enonics radar.