Skip to content

Add Jakarta Bean Validation to request DTOs #38

Description

@tiana-code

Context

Request DTOs must carry Jakarta Bean Validation annotations so that Spring's @Valid mechanism rejects structurally invalid input before it reaches the service layer. Common annotations: @NotNull, @NotBlank, @Size, @Pattern for strings; @Positive for amounts; @NotEmpty for entry lists. Validation errors are mapped to RFC 7807 400 responses by GlobalExceptionHandler.

Acceptance criteria

  • Every non-optional field in every request DTO has an appropriate constraint annotation.
  • currency fields are validated against ISO 4217 pattern (3 uppercase letters).
  • entries list has @NotEmpty and @Size(min=2) to enforce the two-entry minimum before hitting the service.
  • amount fields are validated with @Positive or @DecimalMin(value=0, inclusive=false).
  • @WebMvcTest slice test asserts a missing required field returns 400 with a populated errors[] array.

References

Epic E-01 Ledger Foundation. Wiki: API-Ledger, Code-Rules.

Definition of Done

Tests green; ktlint and detekt clean; coverage target met; reviewed; SPDX header on new files; no maritime or real-provider names.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Critical — blocks release or productionarea:ledgerLedger service (accounts, transactions, balances)effort:S1-4 hourstype:featureNew capability or enhancement

    Projects

    Status
    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions