Skip to content
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

fix: Error count on missing required files #175

Merged
merged 1 commit into from
Apr 4, 2024
Merged
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
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
Loading