verifyReference static method
Verifies a reference based on which fields are left null
or can be found within the bible.
Implementation
static bool verifyReference(dynamic book,
[int? startChapter, int? startVerse, endChapter, endVerse]) {
if (book == null) {
return false;
}
if (book is String) {
book = findBookNumber(book);
}
if (book is! int) return false;
if (!(book > 0 && BibleData.lastVerse.length >= book)) {
return false;
}
if (startChapter != null) {
if (!(startChapter > 0 &&
BibleData.lastVerse[book - 1].length >= startChapter)) {
return false;
}
if (endChapter != null && startChapter > endChapter) {
return false;
}
} else if (endChapter != null || endVerse != null) {
return false;
}
if (startVerse != null) {
if (!(startVerse > 0 &&
BibleData.lastVerse[book - 1][startChapter! - 1] >= startVerse)) {
return false;
}
if (endVerse != null && startVerse > endVerse) {
return false;
}
}
if (endChapter != null) {
if (!(BibleData.lastVerse[book - 1].length >= endChapter)) {
return false;
}
}
endChapter ??= startChapter;
if (endVerse != null) {
if (endChapter == null) {
return false;
}
if (endChapter == null && startVerse == null) {
return false;
} else if (startVerse != null && endVerse < startVerse) {
return false;
} else if (!(endVerse > 0 &&
BibleData.lastVerse[book - 1][endChapter - 1] >= endVerse)) {
return false;
}
}
return true;
}