Skip to content

Commit

Permalink
Error count on missing required files (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessandro100 authored Apr 4, 2024
1 parent 68b2622 commit b3d2358
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gbfs-validator/gbfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ function filesHaveErrors(files) {
*/
function fileHasErrors(fileData, required) {
if (fileHasMultiLanguages(fileData)) {
if(fileData.length === 0 && required) {
return true;
}
return fileData.some((languageBody) => hasErrors(languageBody, required))
}
// So it's not a multi-language array, just check the data directly.
Expand All @@ -61,7 +64,7 @@ function fileHasErrors(fileData, required) {
* @returns {boolean}
*/
function hasErrors(fileData, required) {
if (required && !fileData.exists) {
if (required && (!fileData || !fileData.exists)) {
return true
}
if (!!fileData.errors || fileData.hasErrors) {
Expand All @@ -88,6 +91,10 @@ function fileHasMultiLanguages(fileData) {
function countErrors(file) {
let count = 0

if(file.required && !file.exists) {
count++;
}

if (file.hasErrors) {
if (file.errors) {
count = file.errors.length
Expand Down

0 comments on commit b3d2358

Please sign in to comment.