Skip to content

Commit

Permalink
Merge pull request #78 from abes-esr/CDE-399-les-isbn-a-10-chiffres-s…
Browse files Browse the repository at this point in the history
…ont-rejetes-pour-non-conformite-a-tort

modif regex pour ajouter X + tu
  • Loading branch information
pierre-maraval authored Mar 22, 2024
2 parents cd8ad14 + efab4d3 commit 6bb076a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/fr/abes/sudoc/service/IsbnService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public IsbnService(BaseXmlFunctionsCaller caller) {

@Override
public boolean checkFormat(String isbn) {
return isbn != null && isbn.matches("^[0-9]((?:-?[0-9]){9}|(?:-?[0-9]){12})$");
return isbn != null && isbn.matches("^[0-9]((?:-?[0-9]){9}|(?:-?[0-9]){8}X|(?:-?[0-9]){12})$");
}

@Override
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/fr/abes/sudoc/service/IsbnServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ void checkFormatIsbn10Characters() {

String isbn6 = "-22225-555---3--1";
Assertions.assertFalse(isbnService.checkFormat(isbn6));

String isbn7 = "274758450X";
Assertions.assertTrue(isbnService.checkFormat(isbn7));
}

@Test
Expand Down

0 comments on commit 6bb076a

Please sign in to comment.