mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 04:20:55 +00:00
unload export
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user