diff --git a/src/Command/LoadWarrantySerialCommand.php b/src/Command/LoadWarrantySerialCommand.php index 07ba261a..af587c3d 100644 --- a/src/Command/LoadWarrantySerialCommand.php +++ b/src/Command/LoadWarrantySerialCommand.php @@ -23,7 +23,8 @@ use DateTime; class LoadWarrantySerialCommand extends Command { - const FIELD_COUNT = 7; + const FIELD_COUNT = 7; + const SERIAL_LENGTH = 20; protected $em; protected $upload_logger; @@ -277,8 +278,25 @@ class LoadWarrantySerialCommand extends Command return $data; } - // validate the date created + // check length of serial $serial = trim($row[0]); + if (strlen($serial) > SELF::SERIAL_LENGTH) + { + // log + $error = 'Serial length too long'; + $this->logLoadInfo($user_id, false, $serial, $error); + + $data = [ + 'serial' => $serial, + 'status' => 'error', + 'has_error' => true, + 'error_message' => $error, + ]; + + return $data; + } + + // validate the date created $str_date_create = trim($row[3]); $date_create = $this->convertDateCreate($str_date_create);