How to validate an URL field when using plone.api?

I am creating a view to upload a csv file in order to batch-create items based of a custom Dexterity content type I created for my project.

In the schema for my content type, I created a URL field like this:

link = schema.URI (
    description=_(u"Endereço para acesso pela Internet ao " + 
                  u"texto do ato."),

And in the script for the mass creation of such items, I used plone.api like this:


The "get_cell" references a helper function to process the CSV file (I followed the example here: The get_cell function actually returns the "LINK" column for the current row in the CSV.

Problem is that sometimes the user does not prefixes the URL with "http://", starting the address with "www.". This gives me problems like when I go to the edit form of the created item, the validator complains that the field is not a valid URL.

How should I do to properly validate the field when filling it via plone.api.content.create?

Thanks for your help.

From what I just read on the doc, I should call getValidationErrors and see if it is not empty, after I created the object. If it is not empty, I should delete the object.

Is there a way to validate it during the object creation, in order for it to fail (and not create anything) if a field wouldn't pass validation?