Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Make use of the new unified entity validation functions from metabrainz/bookbrainz-data-js#316.
The main change is that we are now catching the (first)
ValidationError
which is thrown by the validation functions and log it in one central place instead of collecting all error messages and logging them inline in an otherwise identical validation function.I think the change to not log all errors is fine since in most cases there should not be any error.
Since we are reusing the existing validation functions now, we can finally validate series as well.
Through the refactoring we have also lost the nil check for the whole validation object which happened in each validator, but this was unnecessary since we are constructing these (non-empty) objects from the queued entities ourselves.
Some changes which end up being moved into
bookbrainz-data
were done here before the validators have been deleted, so this PR is best reviewed commit by commit.P.S. Unfortunately the separate commits also contain a lot of noise because ESLint forced me to reorder import statements back and forth because of the stupid rule to separate single import and multiple import specifiers. In some cases the addition/removal of imports also caused changes in the alphabetic order... This really made me feel that we should consider ordering imports by module name instead, this would result in a more stable order.