diff --git a/entity_api.inc b/entity_api.inc index dee7e1e..d18076c 100644 --- a/entity_api.inc +++ b/entity_api.inc @@ -237,6 +237,15 @@ class MigrateDestinationEntityAPI extends MigrateDestinationEntity { $updating = (!empty($entity->{$this->id}) && empty($entity->is_new)); + // Validate field data prior to saving. + try { + field_attach_validate($this->entity_type, $entity); + } + catch (FieldValidationException $e) { + // Re-throw this as a normal Exception. + throw new Exception($e->getMessage()); + } + migrate_instrument_start('entity_save'); entity_save($this->entityType, $entity); // It's probably not worth keeping the static cache around. diff --git a/profile2.inc b/profile2.inc index 5a3a4fb..da41fc3 100644 --- a/profile2.inc +++ b/profile2.inc @@ -163,6 +163,15 @@ class MigrateDestinationProfile2 extends MigrateDestinationEntity { $updating = FALSE; } + // Validate field data prior to saving. + try { + field_attach_validate($this->entity_type, $entity); + } + catch (FieldValidationException $e) { + // Re-throw this as a normal Exception. + throw new Exception($e->getMessage()); + } + migrate_instrument_start('entity_save'); entity_save($this->entity_type, $entity); migrate_instrument_stop('entity_save');