unload export

This commit is contained in:
Hagernesh
2026-07-08 19:56:34 +00:00
parent 33956d07dc
commit 99a9bbc291
3 changed files with 21 additions and 2 deletions

View File

@@ -9,14 +9,19 @@ import {
IsOptional,
IsString,
IsUUID,
Matches,
Min,
ValidateNested,
} from 'class-validator';
/** One physical container under a booking line — entered at booking time. */
export class CreateContainerUnitDto {
@ApiProperty()
@ApiProperty({ description: 'ISO 6346 container number, e.g. ABCD1234567' })
@IsString()
@Transform(({ value }) => (typeof value === 'string' ? value.trim().toUpperCase() : value))
@Matches(/^[A-Z]{4}\d{7}$/, {
message: 'containerNumber must match ISO container format, e.g. ABCD1234567',
})
containerNumber!: string;
@ApiPropertyOptional()

View File

@@ -1151,6 +1151,8 @@ function ContainerLineEditor({
render={({ field, fieldState }) => (
<TextInput
{...field}
onChange={(e) => field.onChange(e.currentTarget.value.toUpperCase())}
maxLength={11}
label={u === 0 ? "Container number *" : undefined}
placeholder="e.g. MSCU1234567"
error={fieldState.error?.message}

View File

@@ -26,8 +26,20 @@ export interface ShipmentValidationContext {
requiresDate?: boolean;
}
// ISO 6346: 4 letters (owner + category) + 6 serial digits + 1 check digit.
// Enforced at booking input so the number stays a clean reference in the warehouse.
const ISO_CONTAINER_RE = /^[A-Z]{4}\d{7}$/;
const containerUnitSchema = z.object({
containerNumber: z.string().min(1, "Container number is required."),
containerNumber: z
.string()
.transform((v) => v.trim().toUpperCase())
.pipe(
z
.string()
.min(1, "Container number is required.")
.regex(ISO_CONTAINER_RE, "Use ISO format: 4 letters + 7 digits, e.g. ABCU1234567."),
),
sealNumber: z.string().default(""),
vgmTons: z
.string()