test(shipping): validate platform customer scope separately from business IDs
This commit is contained in:
@@ -16,8 +16,9 @@ function id(value) { return value == null ? '' : String(value) }
|
||||
function number(value) { return Number.isFinite(Number(value)) }
|
||||
function nullableText(value) { return value == null || typeof value === 'string' }
|
||||
function nullableIso(value) { return value == null || (typeof value === 'string' && !Number.isNaN(Date.parse(value))) }
|
||||
function validLongId(value) { return typeof value === 'string' && /^\d{16,}$/.test(value) }
|
||||
function validLongId(value) { return typeof value === 'string' && /^[1-9]\d{15,}$/.test(value) }
|
||||
function validNumericId(value) { return typeof value === 'string' && /^\d+$/.test(value) && value !== '0' }
|
||||
function validCustomerScope(value) { return typeof value === 'string' && /^(?:0|[1-9]\d*)$/.test(value) }
|
||||
function validOperatorId(value) { return value === '0' || validNumericId(value) }
|
||||
function validContainerNo(value) {
|
||||
if (typeof value !== 'string' || !ISO_CONTAINER_PATTERN.test(value)) return false
|
||||
@@ -69,7 +70,7 @@ export function manualNodePayload({ expectedVersion, standardNode, observedAt, e
|
||||
}
|
||||
|
||||
function validTask(task) {
|
||||
return validLongId(task?.id) && Boolean(task?.queryNo) && validNumericId(task?.customerId)
|
||||
return validLongId(task?.id) && Boolean(task?.queryNo) && validCustomerScope(task?.customerId)
|
||||
&& validLongId(task?.oceanBookingId) && QUERY_STATUSES.includes(task?.status)
|
||||
&& validLongId(task?.containerBookingId) && task?.trackingType === 'CONTAINER_NO'
|
||||
&& validContainerNo(task?.trackingNo) && nullableText(task?.latestActualNode)
|
||||
|
||||
Reference in New Issue
Block a user