Add checking for serial length. #707

This commit is contained in:
Korina Cordero 2022-09-26 06:46:45 +00:00
parent 72dab63503
commit b8c0fa9932

View file

@ -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);