diff --git a/kafka-spring-boot/boot-kafka-sample/src/main/java/com/example/springbootkafkasample/dto/KafkaListenerRequest.java b/kafka-spring-boot/boot-kafka-sample/src/main/java/com/example/springbootkafkasample/dto/KafkaListenerRequest.java index c73d3ff7..5b25b87f 100644 --- a/kafka-spring-boot/boot-kafka-sample/src/main/java/com/example/springbootkafkasample/dto/KafkaListenerRequest.java +++ b/kafka-spring-boot/boot-kafka-sample/src/main/java/com/example/springbootkafkasample/dto/KafkaListenerRequest.java @@ -5,7 +5,9 @@ import jakarta.validation.constraints.Pattern; public record KafkaListenerRequest( - @NotBlank(message = "Container ID must not be blank") - @Pattern(regexp = "^\\S.*$", message = "Container ID must not start with whitespace") - String containerId, + @NotBlank(message = "Container ID must not be blank") @Pattern( + regexp = "^[a-zA-Z0-9\\-_.]+$", + message = + "Container ID must contain only alphanumeric characters, hyphens, underscores, and dots") + @Pattern(regexp = "^\\S.*$", message = "Container ID must not start with whitespace") String containerId, @NotNull(message = "Operation must not be null") Operation operation) {}