protected function RangeMigrateFieldHandler::validate in Range 7
Validates given range field value item.
Parameters
object $entity: Entity being processed.
array $field_info: Field info.
array $instance: Field instance.
array $item: Field values delta.
Return value
bool Returns TRUE if given item contains valid range field value, FALSE - otherwise.
1 call to RangeMigrateFieldHandler::validate()
- RangeMigrateFieldHandler::prepare in migrate/
destinations/ range.inc
File
- migrate/
destinations/ range.inc, line 148 - Contains range field migration handler.
Class
- RangeMigrateFieldHandler
- Range field migration handler class.
Code
protected function validate($entity, array $field_info, array $instance, array $item) {
$item_is_valid = TRUE;
$migration = Migration::currentMigration();
if ((string) $item['from'] === '' || (string) $item['to'] === '') {
$migration
->saveMessage(t('%name: both FROM and TO values are required.', array(
'%name' => $instance['label'],
)), Migration::MESSAGE_ERROR);
$item_is_valid = FALSE;
}
if (!is_numeric($item['from']) || !is_numeric($item['to'])) {
$migration
->saveMessage(t('%name: only numeric values are acceptable.', array(
'%name' => $instance['label'],
)), Migration::MESSAGE_ERROR);
$item_is_valid = FALSE;
}
if ($field_info['type'] === 'range_integer' && (!ctype_digit($item['from']) || !ctype_digit($item['to']))) {
$migration
->saveMessage(t('%name: is an integer range, however float point values were found.', array(
'%name' => $instance['label'],
)), Migration::MESSAGE_WARNING);
}
return $item_is_valid;
}