Skip to content

validate isbn 13 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public boolean isValid(String value, ConstraintValidatorContext context) {
// Don't validate null, empty and blank strings, since these are validated by @NotNull,
// @NotEmpty and @NotBlank
if (StringUtils.isNotBlank(value)) {
return ISBNValidator.getInstance().isValidISBN10(value);
return ISBNValidator.getInstance().isValidISBN10(value)
|| ISBNValidator.getInstance().isValidISBN13(value);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ empty.bookDataFormData.edition=Edition is mandatory
empty.bookDataFormData.author=Author is mandatory
empty.bookDataFormData.isbn=ISBN is mandatory
notvalid.bookDataFormData.edition=Please enter a numeric value.
notvalid.bookDataFormData.isbn=Please enter a valid 10 characters ISBN.
notvalid.bookDataFormData.isbn=Please enter a valid 10 or 13 characters ISBN.
notvalid.bookDataFormData.yearOfPublication=Please enter a four-digit year.
invalid.length.bookDataFormData.yearOfPublication=Please enter a four-digit year.

# Borrow book form
notvalid.borrowCmd.isbn=Please enter a valid 10 characters ISBN.
notvalid.borrowCmd.isbn=Please enter a valid 10 or 13 characters ISBN.
empty.borrowCmd.isbn=ISBN is mandatory
notvalid.borrowCmd.email=Please enter a valid Email.
empty.borrowCmd.email=Email is mandatory

# Return all books form
empty.returnAllBookFormData.emailAddress=Email is mandatory
notvalid.returnAllBookFormData.emailAddress=Please enter a valid Email.
notvalid.returnAllBookFormData.isbn=Please enter a valid 10 characters ISBN.
notvalid.returnAllBookFormData.isbn=Please enter a valid 10 or 13 characters ISBN.

# Default messages for custom validators
de.codecentric.psd.worblehat.web.validation.ISBN=Please enter a valid 10 characters ISBN.
de.codecentric.psd.worblehat.web.validation.ISBN=Please enter a valid 10 or 13 characters ISBN.
de.codecentric.psd.worblehat.web.validation.Numeric=Value has to be numeric