'postal_greeting_id',
'addressee',
'addressee_id',
+ 'geo_code_1',
+ 'geo_code_2',
];
/**
}
break;
- case 'geo_code_1':
- if (!empty($value)) {
- foreach ($value as $codeValue) {
- if (!empty($codeValue['geo_code_1'])) {
- if (CRM_Utils_Rule::numeric($codeValue['geo_code_1'])) {
- continue;
- }
- $errors[] = ts('Geo code 1');
- }
- }
- }
- break;
-
- case 'geo_code_2':
- if (!empty($value)) {
- foreach ($value as $codeValue) {
- if (!empty($codeValue['geo_code_2'])) {
- if (CRM_Utils_Rule::numeric($codeValue['geo_code_2'])) {
- continue;
- }
- $errors[] = ts('Geo code 2');
- }
- }
- }
- break;
-
case 'do_not_email':
case 'do_not_phone':
case 'do_not_mail':
return CRM_Utils_Rule::email($importedValue) ? $importedValue : 'invalid_import_value';
}
+ if ($fieldMetadata['type'] === CRM_Utils_Type::T_FLOAT) {
+ return CRM_Utils_Rule::numeric($importedValue) ? $importedValue : 'invalid_import_value';
+ }
if ($fieldMetadata['type'] === CRM_Utils_Type::T_BOOLEAN) {
$value = CRM_Utils_String::strtoboolstr($importedValue);
if ($value !== FALSE) {
--- /dev/null
+first_name,last_name,geocodeone,GeoCodetwo,expected
+Madame,1,1,-1,Valid
+Madame,2,a,b,Invalid
+Madame,3,1.1123,-1.1123,Valid
return $userJobID;
}
+ /**
+ * Test geocode validation.
+ *
+ * @throws \API_Exception
+ * @throws \CRM_Core_Exception
+ */
+ public function testImportGeocodes(): void {
+ $mapper = [
+ ['first_name'],
+ ['last_name'],
+ ['geo_code_1', 1],
+ ['geo_code_2', 1],
+ ];
+ $csv = 'individual_geocode.csv';
+ $this->validateMultiRowCsv($csv, $mapper, 'GeoCode2');
+ }
+
/**
* Validate the csv file values.
*