Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ const catchCertificateTransportDetailsSchema = Joi.object({
.items(
Joi.string()
.trim()
.max(50)
.regex(/^$|^[a-zA-Z0-9]+$/)
.messages({
'string.pattern.base': 'ccAddTransportationDetailsContainerIdentificationNumberOnlyNumLettersError',
'string.max': 'ccContainerIdentificationNumberMaxLength',
})
)
.min(1)
Expand Down
3 changes: 2 additions & 1 deletion src/schemas/catchcerts/planeSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ const schema = Joi.object({
}),
containerNumber: Joi.string().trim().optional().regex(/^[a-zA-Z0-9 ]+$/).optional(),
containerNumbers: Joi.array()
.items(Joi.string().trim().regex(/^[a-zA-Z0-9]+$/).messages({
.items(Joi.string().trim().max(50).regex(/^[a-zA-Z0-9]+$/).messages({
'string.pattern.base': 'error.containerNumbers.string.pattern.base',
'string.max': 'error.containerNumbers.string.max',
}))
.unique((a, b) => a && b && a.trim() === b.trim())
.min(1)
Expand Down
19 changes: 19 additions & 0 deletions src/services/progress.service.jest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2512,6 +2512,25 @@ describe('getTransportDetails', () => {
);
});

it('should return INCOMPLETE for a plane with a containerNumbers entry exceeding 50 characters', () => {
const transport: Transport = {
vehicle: 'plane',
exportedTo: {
officialCountryName: 'Brazil',
isoCodeAlpha2: 'BR',
isoCodeAlpha3: 'BRA',
isoNumericCode: '076',
},
flightNumber: 'BA123',
departurePlace: 'London Heathrow',
containerNumbers: ['A'.repeat(51)],
};

expect(ProgressService.getTransportDetails(transport)).toBe(
ProgressStatus.INCOMPLETE
);
});

it('should return INCOMPLETED for a container vessel with a departure place with validation errors', () => {
const transport: Transport = {
vehicle: 'containerVessel',
Expand Down
Loading