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 :)
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
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