Skip to content

Commit

Permalink
UIQM-711: Update �alidateFixedFieldPositions to display all 008 field…
Browse files Browse the repository at this point in the history
… errors instead of one in Bibliographic records. (#747)
  • Loading branch information
Dmytro-Melnyshyn authored Oct 15, 2024
1 parent 92e2366 commit d99cee5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* [UIQM-714](https://issues.folio.org/browse/UIQM-714) *BREAKING* Upgrade `inventory` to `14.0`.
* [UIQM-709](https://issues.folio.org/browse/UIQM-709) LCCN duplication: Update the bib request query to include only the non-suppressed record in the search results.
* [UIQM-701](https://issues.folio.org/browse/UIQM-701) Use new GA workflows.
* [UIQM-711](https://issues.folio.org/browse/UIQM-711) Update `validateFixedFieldPositions` to display all 008 field errors instead of one in Bibliographic records.

## [8.0.1] (https://github.com/folio-org/ui-quick-marc/tree/v8.0.1) (2024-04-18)

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useValidation/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export const validateFixedFieldPositions = ({ marcRecords, fixedFieldSpec, marcT
const subFieldContentArray = Array.isArray(contents) ? contents : [contents];

if (!subFieldContentArray.every(content => subField.allowedValues.find(value => value.code === content))) {
return { ...acc, [field.id]: [rule.message(subField.code)] };
acc[field.id] = [...(acc[field.id] || []), rule.message(subField.code)];
}
}

Expand Down
19 changes: 19 additions & 0 deletions src/hooks/useValidation/validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,25 @@ describe('validators', () => {

expect(rule.message).toHaveBeenCalledWith('Ills');
});

it('should return all errors instead of one', () => {
const marcRecords = [{
tag: LEADER_TAG,
content: bibLeader,
}, {
id: 'id-008',
tag: FIXED_FIELD_TAG,
content: {
DtSt: '_',
Ills: '_',
},
}];
const marcType = MARC_TYPES.BIB;

const errors = validators.validateFixedFieldPositions({ marcRecords, fixedFieldSpec, marcType }, rule);

expect(errors['id-008'].length).toBe(2);
});
});

describe('validateLccnDuplication', () => {
Expand Down

0 comments on commit d99cee5

Please sign in to comment.