Skip to content

Commit

Permalink
fix errors description in isValidDateArg()
Browse files Browse the repository at this point in the history
  • Loading branch information
itmor committed May 29, 2020
1 parent 5117cf8 commit d15e513
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build/calendar-array.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions src/calendar-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@ class CalendarArray {
}
}

/*
Validates getCalendar arguments.
- sample correct arguments
[[2020, 3], [2012], [2007]]
*/
#isValidDateArg(dates) {
// Sample correct arguments [[2020, 3], [2012], [2007]]
if (dates.length > 0) {
for (let date of dates) {

if (!Array.isArray(date)) {
throw new TypeError(`type: ${typeof date} <- the argument is of the wrong type, array expected`);
throw new TypeError(`Invalid type, array expected, ${typeof date} passed`);

} else if (date.length === 0) {
throw new Error(`length: ${date.length} <- array is empty`);
throw new Error(`Array is empty`);
} else {

for (let value of date) {
if (typeof value !== 'number') {
throw new TypeError(`type: ${typeof value} <- invalid date type in this array of dates, expected number`);
throw new TypeError(`Invalid type, number expected, ${typeof value} passed`);
}
}
}
Expand Down

0 comments on commit d15e513

Please sign in to comment.