r-adelaide / cheltham

Library management app for Salesforce
1 stars 10 forks source link

Isbn validator #46

Open MahanGhobadi opened 4 years ago

MahanGhobadi commented 4 years ago

This version of ISBNValidator class has been refactored and its test classes have been redesigned to avoid using fuzzy testing techniques. The class has broken down into two main methods:

  1. hasCorrectFormat(): Checks whether the ISBN code has a proper length, or only contains digits, and even in some 10 digit ISBN cases whether there is X at the end, etc. The method does not care . whether x is capitalised or not,

  2. checkISBNValidation(): Checks whether ISBN can be a correct ISBN but checking the checksum against the rest of the 12 or 9 digit code.

For the sake of consistency and ease of use, every 10 digit ISBN will always be converted to its 13 digit equivalent ISBN code.

For further information how the conversion formula works, please refer to following http://mathworld.wolfram.com/ISBN.html