From 20d628e0f64b50b801952c0b76a8038379c3e26e Mon Sep 17 00:00:00 2001 From: Ajay Negi <97536703+ajaynegi45@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:15:59 +0530 Subject: [PATCH] Updated the isbn pattern --- src/main/java/com/libraryman_api/book/BookDto.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/libraryman_api/book/BookDto.java b/src/main/java/com/libraryman_api/book/BookDto.java index a7349a1..b47ee13 100644 --- a/src/main/java/com/libraryman_api/book/BookDto.java +++ b/src/main/java/com/libraryman_api/book/BookDto.java @@ -15,9 +15,13 @@ public class BookDto { private String author; @NotBlank(message = "isbn is required") - @Pattern(regexp = "^(978|979)-\\d{10}$", message = "Invalid ISBN format. Format must be '978-XXXXXXXXXX' or '979-XXXXXXXXXX'") + @Pattern( + regexp = "^(?:\\d{9}[\\dX]|(?:(978|979)-)?\\d{1,5}-\\d{1,7}-\\d{1,7}-\\d{1})$", + message = "Invalid ISBN format. Valid formats include 'XXXXXXXXXX', 'XXXXXXXXXX-X', '978-XXXXXXXXXX', '978-X-XX-XXXXXX-X', etc." + ) private String isbn; + @NotBlank(message = "Publisher is required") @Size(min = 1, max = 100, message = "Publisher name must be between 1 and 100 characters") private String publisher;