Unfortunately it does not seem to be possible at that time, because validation is only made by the content/edit module.
However, every datatype has a validateObjectAttributeHTTPInput() method, but as its name indicates it, it is based on HTTP. I guess you could fake it by using eZHTTPTool and provide fake POST variables, while this is not the cleanest thing I could advise...
Anyway, instead of using eZContentFunctions::createAndPublishObject(), you might want to use SQLIImport extension which contains a simplified content API. It does not allow (yet) to validate data, but this is an interesting idea :)
Paul Etienney
Tuesday 30 November 2010 1:17:02 am
Hello Jérôme.
Thanks for your reply. I guess you have a gazillion kilometers long todo list but it would great to be able to easily check attributes.
Having attribute validation decoupled from HTTP is imho one one of the most important advancements we need at this point in time in the eZP content model:
- it prevents creation of webservices / cli scripts / other APIS that create content without going through the monster that content/edit is
- it makes creation and validation of import scripts a chore. Almost every website I have audited where import scripts had been developed had some inconsistent data in the db
So I'd rather push to fix this in the kernel than add it to an extension...
Principal Consultant International Business
Member of the Community Project Board
Gaetano Giunta
Tuesday 30 November 2010 1:53:52 am
ps: this is also true for content imported via packages. Just test this: set an object-relation attribute as required in a class, create an obj, export it in a package (but omit its related obj), import it. You end up with an object that does not comply with your class spec...
Principal Consultant International Business
Member of the Community Project Board
Paul Etienney
Tuesday 30 November 2010 1:58:38 am
Hello Gaeano,
Good to hear that. I guess many people would love to check attributes easily.
Do you think it is a lot of work to fix this in the kernel ?