@natlibfi/marc-record-validators-melinda 3.2.0 → 3.3.14-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/CODEOWNERS +2 -0
- package/.github/dependabot.yml +40 -0
- package/.github/workflows/melinda-node-tests.yml +61 -0
- package/LICENSE.txt +21 -661
- package/README.md +4 -5
- package/dist/access-rights.js +94 -0
- package/dist/access-rights.js.map +1 -0
- package/dist/access-rights.spec.js +150 -0
- package/dist/access-rights.spec.js.map +1 -0
- package/dist/double-commas.js +17 -27
- package/dist/double-commas.js.map +1 -1
- package/dist/double-commas.spec.js +72 -27
- package/dist/double-commas.spec.js.map +1 -1
- package/dist/duplicates-ind1.js +47 -27
- package/dist/duplicates-ind1.js.map +1 -1
- package/dist/duplicates-ind1.spec.js +44 -27
- package/dist/duplicates-ind1.spec.js.map +1 -1
- package/dist/empty-fields.js +79 -29
- package/dist/empty-fields.js.map +1 -1
- package/dist/empty-fields.spec.js +113 -27
- package/dist/empty-fields.spec.js.map +1 -1
- package/dist/ending-punctuation-conf.js +772 -129
- package/dist/ending-punctuation-conf.js.map +1 -1
- package/dist/ending-punctuation.js +291 -72
- package/dist/ending-punctuation.js.map +1 -1
- package/dist/ending-punctuation.spec.js +2638 -118
- package/dist/ending-punctuation.spec.js.map +1 -1
- package/dist/ending-whitespace.js +58 -0
- package/dist/ending-whitespace.js.map +1 -0
- package/dist/ending-whitespace.spec.js +42 -0
- package/dist/ending-whitespace.spec.js.map +1 -0
- package/dist/field-521-fix.js +96 -0
- package/dist/field-521-fix.js.map +1 -0
- package/dist/field-521-fix.spec.js +51 -0
- package/dist/field-521-fix.spec.js.map +1 -0
- package/dist/field-exclusion.js +214 -63
- package/dist/field-exclusion.js.map +1 -1
- package/dist/field-exclusion.spec.js +1057 -31
- package/dist/field-exclusion.spec.js.map +1 -1
- package/dist/field-structure.js +249 -78
- package/dist/field-structure.js.map +1 -1
- package/dist/field-structure.spec.js +534 -31
- package/dist/field-structure.spec.js.map +1 -1
- package/dist/fields-present.js +31 -27
- package/dist/fields-present.js.map +1 -1
- package/dist/fields-present.spec.js +120 -27
- package/dist/fields-present.spec.js.map +1 -1
- package/dist/fixed-fields.js +72 -27
- package/dist/fixed-fields.js.map +1 -1
- package/dist/fixed-fields.spec.js +139 -27
- package/dist/fixed-fields.spec.js.map +1 -1
- package/dist/identical-fields.js +42 -28
- package/dist/identical-fields.js.map +1 -1
- package/dist/identical-fields.spec.js +98 -27
- package/dist/identical-fields.spec.js.map +1 -1
- package/dist/index.js +202 -27
- package/dist/index.js.map +1 -1
- package/dist/indicator-fixes.js +191 -0
- package/dist/indicator-fixes.js.map +1 -0
- package/dist/indicator-fixes.spec.js +51 -0
- package/dist/indicator-fixes.spec.js.map +1 -0
- package/dist/isbn-issn.js +266 -27
- package/dist/isbn-issn.js.map +1 -1
- package/dist/isbn-issn.spec.js +594 -27
- package/dist/isbn-issn.spec.js.map +1 -1
- package/dist/item-language.js +171 -27
- package/dist/item-language.js.map +1 -1
- package/dist/item-language.spec.js +305 -27
- package/dist/item-language.spec.js.map +1 -1
- package/dist/mergeField500Lisapainokset.js +155 -0
- package/dist/mergeField500Lisapainokset.js.map +1 -0
- package/dist/mergeField500Lisapainokset.spec.js +51 -0
- package/dist/mergeField500Lisapainokset.spec.js.map +1 -0
- package/dist/mergeRelatorTermFields.js +140 -0
- package/dist/mergeRelatorTermFields.js.map +1 -0
- package/dist/mergeRelatorTermFields.spec.js +51 -0
- package/dist/mergeRelatorTermFields.spec.js.map +1 -0
- package/dist/multiple-subfield-0.js +120 -0
- package/dist/multiple-subfield-0.js.map +1 -0
- package/dist/multiple-subfield-0.spec.js +51 -0
- package/dist/multiple-subfield-0.spec.js.map +1 -0
- package/dist/non-breaking-space.js +61 -0
- package/dist/non-breaking-space.js.map +1 -0
- package/dist/non-breaking-space.spec.js +42 -0
- package/dist/non-breaking-space.spec.js.map +1 -0
- package/dist/normalize-identifiers.js +210 -0
- package/dist/normalize-identifiers.js.map +1 -0
- package/dist/normalize-identifiers.spec.js +51 -0
- package/dist/normalize-identifiers.spec.js.map +1 -0
- package/dist/normalize-utf8-diacritics.js +140 -0
- package/dist/normalize-utf8-diacritics.js.map +1 -0
- package/dist/normalize-utf8-diacritics.spec.js +51 -0
- package/dist/normalize-utf8-diacritics.spec.js.map +1 -0
- package/dist/punctuation/index.js +281 -0
- package/dist/punctuation/index.js.map +1 -0
- package/dist/punctuation/rules/aut.js +332 -0
- package/dist/punctuation/rules/aut.js.map +1 -0
- package/dist/punctuation/rules/bib.js +374 -0
- package/dist/punctuation/rules/bib.js.map +1 -0
- package/dist/punctuation/rules/index.js +21 -0
- package/dist/punctuation/rules/index.js.map +1 -0
- package/dist/punctuation.spec.js +51 -0
- package/dist/punctuation.spec.js.map +1 -0
- package/dist/punctuation2.js +726 -0
- package/dist/punctuation2.js.map +1 -0
- package/dist/punctuation2.spec.js +51 -0
- package/dist/punctuation2.spec.js.map +1 -0
- package/dist/reindexSubfield6OccurenceNumbers.js +199 -0
- package/dist/reindexSubfield6OccurenceNumbers.js.map +1 -0
- package/dist/reindexSubfield6OccurenceNumbers.spec.js +51 -0
- package/dist/reindexSubfield6OccurenceNumbers.spec.js.map +1 -0
- package/dist/removeDuplicateDataFields.js +405 -0
- package/dist/removeDuplicateDataFields.js.map +1 -0
- package/dist/removeDuplicateDataFields.spec.js +51 -0
- package/dist/removeDuplicateDataFields.spec.js.map +1 -0
- package/dist/removeInferiorDataFields.js +245 -0
- package/dist/removeInferiorDataFields.js.map +1 -0
- package/dist/removeInferiorDataFields.spec.js +51 -0
- package/dist/removeInferiorDataFields.spec.js.map +1 -0
- package/dist/resolvable-ext-references-melinda.js +112 -31
- package/dist/resolvable-ext-references-melinda.js.map +1 -1
- package/dist/resolvable-ext-references-melinda.spec.js +166 -27
- package/dist/resolvable-ext-references-melinda.spec.js.map +1 -1
- package/dist/resolveOrphanedSubfield6s.js +116 -0
- package/dist/resolveOrphanedSubfield6s.js.map +1 -0
- package/dist/resolveOrphanedSubfield6s.spec.js +51 -0
- package/dist/resolveOrphanedSubfield6s.spec.js.map +1 -0
- package/dist/sanitize-vocabulary-source-codes.js +93 -0
- package/dist/sanitize-vocabulary-source-codes.js.map +1 -0
- package/dist/sanitize-vocabulary-source-codes.spec.js +51 -0
- package/dist/sanitize-vocabulary-source-codes.spec.js.map +1 -0
- package/dist/sort-tags.js +53 -27
- package/dist/sort-tags.js.map +1 -1
- package/dist/sort-tags.spec.js +206 -27
- package/dist/sort-tags.spec.js.map +1 -1
- package/dist/sortRelatorTerms.js +135 -0
- package/dist/sortRelatorTerms.js.map +1 -0
- package/dist/sortRelatorTerms.spec.js +51 -0
- package/dist/sortRelatorTerms.spec.js.map +1 -0
- package/dist/sortSubfields.js +279 -0
- package/dist/sortSubfields.js.map +1 -0
- package/dist/sortSubfields.spec.js +51 -0
- package/dist/sortSubfields.spec.js.map +1 -0
- package/dist/stripPunctuation.js +49 -0
- package/dist/stripPunctuation.js.map +1 -0
- package/dist/stripPunctuation.spec.js +51 -0
- package/dist/stripPunctuation.spec.js.map +1 -0
- package/dist/subfield-exclusion.js +174 -57
- package/dist/subfield-exclusion.js.map +1 -1
- package/dist/subfield-exclusion.spec.js +521 -31
- package/dist/subfield-exclusion.spec.js.map +1 -1
- package/dist/subfield6Utils.js +457 -0
- package/dist/subfield6Utils.js.map +1 -0
- package/dist/subfield8Utils.js +99 -0
- package/dist/subfield8Utils.js.map +1 -0
- package/dist/typeOfDate-008.js +48 -0
- package/dist/typeOfDate-008.js.map +1 -0
- package/dist/typeOfDate-008.spec.js +47 -0
- package/dist/typeOfDate-008.spec.js.map +1 -0
- package/dist/unicode-decomposition.js +139 -30
- package/dist/unicode-decomposition.js.map +1 -1
- package/dist/unicode-decomposition.spec.js +90 -27
- package/dist/unicode-decomposition.spec.js.map +1 -1
- package/dist/update-field-540.js +119 -0
- package/dist/update-field-540.js.map +1 -0
- package/dist/update-field-540.spec.js +51 -0
- package/dist/update-field-540.spec.js.map +1 -0
- package/dist/urn.js +185 -0
- package/dist/urn.js.map +1 -0
- package/dist/urn.spec.js +238 -0
- package/dist/urn.spec.js.map +1 -0
- package/dist/utils.js +58 -0
- package/dist/utils.js.map +1 -0
- package/package.json +114 -124
- package/src/access-rights.js +84 -0
- package/src/access-rights.spec.js +126 -0
- package/src/double-commas.js +12 -49
- package/src/double-commas.spec.js +50 -82
- package/src/duplicates-ind1.js +34 -74
- package/src/duplicates-ind1.spec.js +39 -117
- package/src/empty-fields.js +62 -74
- package/src/empty-fields.spec.js +134 -207
- package/src/ending-punctuation-conf.js +679 -644
- package/src/ending-punctuation.js +260 -250
- package/src/ending-punctuation.spec.js +2545 -2322
- package/src/ending-whitespace.js +40 -0
- package/src/ending-whitespace.spec.js +44 -0
- package/src/field-521-fix.js +92 -0
- package/src/field-521-fix.spec.js +52 -0
- package/src/field-exclusion.js +197 -215
- package/src/field-exclusion.spec.js +883 -481
- package/src/field-structure.js +213 -271
- package/src/field-structure.spec.js +597 -474
- package/src/fields-present.js +19 -49
- package/src/fields-present.spec.js +90 -91
- package/src/fixed-fields.js +61 -94
- package/src/fixed-fields.spec.js +81 -125
- package/src/identical-fields.js +29 -48
- package/src/identical-fields.spec.js +114 -146
- package/src/index.js +41 -46
- package/src/indicator-fixes.js +211 -0
- package/src/indicator-fixes.spec.js +52 -0
- package/src/isbn-issn.js +254 -106
- package/src/isbn-issn.spec.js +399 -172
- package/src/item-language.js +158 -195
- package/src/item-language.spec.js +314 -306
- package/src/mergeField500Lisapainokset.js +153 -0
- package/src/mergeField500Lisapainokset.spec.js +52 -0
- package/src/mergeRelatorTermFields.js +143 -0
- package/src/mergeRelatorTermFields.spec.js +52 -0
- package/src/multiple-subfield-0.js +129 -0
- package/src/multiple-subfield-0.spec.js +52 -0
- package/src/non-breaking-space.js +49 -0
- package/src/non-breaking-space.spec.js +44 -0
- package/src/normalize-identifiers.js +197 -0
- package/src/normalize-identifiers.spec.js +52 -0
- package/src/normalize-utf8-diacritics.js +141 -0
- package/src/normalize-utf8-diacritics.spec.js +52 -0
- package/src/punctuation/index.js +292 -0
- package/src/punctuation/rules/aut.js +372 -0
- package/src/punctuation/rules/bib.js +420 -0
- package/src/punctuation/rules/index.js +7 -0
- package/src/punctuation.spec.js +52 -0
- package/src/punctuation2.js +441 -0
- package/src/punctuation2.spec.js +52 -0
- package/src/reindexSubfield6OccurenceNumbers.js +210 -0
- package/src/reindexSubfield6OccurenceNumbers.spec.js +52 -0
- package/src/removeDuplicateDataFields.js +447 -0
- package/src/removeDuplicateDataFields.spec.js +52 -0
- package/src/removeInferiorDataFields.js +259 -0
- package/src/removeInferiorDataFields.spec.js +52 -0
- package/src/resolvable-ext-references-melinda.js +89 -122
- package/src/resolvable-ext-references-melinda.spec.js +168 -198
- package/src/resolveOrphanedSubfield6s.js +115 -0
- package/src/resolveOrphanedSubfield6s.spec.js +52 -0
- package/src/sanitize-vocabulary-source-codes.js +99 -0
- package/src/sanitize-vocabulary-source-codes.spec.js +52 -0
- package/src/sort-tags.js +34 -60
- package/src/sort-tags.spec.js +256 -290
- package/src/sortRelatorTerms.js +142 -0
- package/src/sortRelatorTerms.spec.js +52 -0
- package/src/sortSubfields.js +176 -0
- package/src/sortSubfields.spec.js +52 -0
- package/src/stripPunctuation.js +42 -0
- package/src/stripPunctuation.spec.js +52 -0
- package/src/subfield-exclusion.js +157 -180
- package/src/subfield-exclusion.spec.js +507 -453
- package/src/subfield6Utils.js +485 -0
- package/src/subfield8Utils.js +102 -0
- package/src/typeOfDate-008.js +40 -0
- package/src/typeOfDate-008.spec.js +47 -0
- package/src/unicode-decomposition.js +130 -145
- package/src/unicode-decomposition.spec.js +89 -115
- package/src/update-field-540.js +99 -0
- package/src/update-field-540.spec.js +52 -0
- package/src/urn.js +164 -0
- package/src/urn.spec.js +231 -0
- package/src/utils.js +52 -0
- package/test-fixtures/duplicates-ind1/01/expectedResult.json +4 -0
- package/test-fixtures/duplicates-ind1/01/metadata.json +4 -0
- package/test-fixtures/duplicates-ind1/01/record.json +16 -0
- package/test-fixtures/duplicates-ind1/02/expectedResult.json +6 -0
- package/test-fixtures/duplicates-ind1/02/metadata.json +4 -0
- package/test-fixtures/duplicates-ind1/02/record.json +16 -0
- package/test-fixtures/duplicates-ind1/03/expectedResult.json +13 -0
- package/test-fixtures/duplicates-ind1/03/metadata.json +6 -0
- package/test-fixtures/duplicates-ind1/03/record.json +16 -0
- package/test-fixtures/ending-whitespace/01/expectedResult.json +4 -0
- package/test-fixtures/ending-whitespace/01/metadata.json +6 -0
- package/test-fixtures/ending-whitespace/01/record.json +15 -0
- package/test-fixtures/ending-whitespace/02/expectedResult.json +4 -0
- package/test-fixtures/ending-whitespace/02/metadata.json +6 -0
- package/test-fixtures/ending-whitespace/02/record.json +15 -0
- package/test-fixtures/ending-whitespace/03/expectedResult.json +17 -0
- package/test-fixtures/ending-whitespace/03/metadata.json +6 -0
- package/test-fixtures/ending-whitespace/03/record.json +15 -0
- package/test-fixtures/ending-whitespace/04/expectedResult.json +10 -0
- package/test-fixtures/ending-whitespace/04/metadata.json +6 -0
- package/test-fixtures/ending-whitespace/04/record.json +8 -0
- package/test-fixtures/fix521/01/expectedResult.json +6 -0
- package/test-fixtures/fix521/01/metadata.json +5 -0
- package/test-fixtures/fix521/01/record.json +13 -0
- package/test-fixtures/fix521/02/expectedResult.json +15 -0
- package/test-fixtures/fix521/02/metadata.json +5 -0
- package/test-fixtures/fix521/02/record.json +13 -0
- package/test-fixtures/fix521/03/expectedResult.json +5 -0
- package/test-fixtures/fix521/03/metadata.json +5 -0
- package/test-fixtures/fix521/03/record.json +13 -0
- package/test-fixtures/indicator-fixes/01/expectedResult.json +9 -0
- package/test-fixtures/indicator-fixes/01/metadata.json +5 -0
- package/test-fixtures/indicator-fixes/01/record.json +64 -0
- package/test-fixtures/indicator-fixes/02/expectedResult.json +66 -0
- package/test-fixtures/indicator-fixes/02/metadata.json +5 -0
- package/test-fixtures/indicator-fixes/02/record.json +64 -0
- package/test-fixtures/indicator-fixes/03/expectedResult.json +55 -0
- package/test-fixtures/indicator-fixes/03/metadata.json +5 -0
- package/test-fixtures/indicator-fixes/03/record.json +54 -0
- package/test-fixtures/indicator-fixes/04/expectedResult.json +66 -0
- package/test-fixtures/indicator-fixes/04/metadata.json +5 -0
- package/test-fixtures/indicator-fixes/04/record.json +65 -0
- package/test-fixtures/indicator-fixes/05/expectedResult.json +66 -0
- package/test-fixtures/indicator-fixes/05/metadata.json +5 -0
- package/test-fixtures/indicator-fixes/05/record.json +65 -0
- package/test-fixtures/indicator-fixes/06/expectedResult.json +75 -0
- package/test-fixtures/indicator-fixes/06/metadata.json +5 -0
- package/test-fixtures/indicator-fixes/06/record.json +74 -0
- package/test-fixtures/lisapainokset/fixer/01/expectedResult.json +37 -0
- package/test-fixtures/lisapainokset/fixer/01/metadata.json +6 -0
- package/test-fixtures/lisapainokset/fixer/01/record.json +61 -0
- package/test-fixtures/lisapainokset/fixer/02/expectedResult.json +44 -0
- package/test-fixtures/lisapainokset/fixer/02/metadata.json +6 -0
- package/test-fixtures/lisapainokset/fixer/02/record.json +45 -0
- package/test-fixtures/lisapainokset/fixer/03/expectedResult.json +21 -0
- package/test-fixtures/lisapainokset/fixer/03/metadata.json +6 -0
- package/test-fixtures/lisapainokset/fixer/03/record.json +45 -0
- package/test-fixtures/lisapainokset/validator/01/expectedResult.json +7 -0
- package/test-fixtures/lisapainokset/validator/01/metadata.json +6 -0
- package/test-fixtures/lisapainokset/validator/01/record.json +45 -0
- package/test-fixtures/lisapainokset/validator/02/expectedResult.json +6 -0
- package/test-fixtures/lisapainokset/validator/02/metadata.json +6 -0
- package/test-fixtures/lisapainokset/validator/02/record.json +61 -0
- package/test-fixtures/lisapainokset/validator/03/expectedResult.json +4 -0
- package/test-fixtures/lisapainokset/validator/03/metadata.json +6 -0
- package/test-fixtures/lisapainokset/validator/03/record.json +37 -0
- package/test-fixtures/mergeRelatorTermFields/fixer/01/expectedResult.json +14 -0
- package/test-fixtures/mergeRelatorTermFields/fixer/01/metadata.json +6 -0
- package/test-fixtures/mergeRelatorTermFields/fixer/01/record.json +16 -0
- package/test-fixtures/mergeRelatorTermFields/fixer/02/expectedResult.json +17 -0
- package/test-fixtures/mergeRelatorTermFields/fixer/02/metadata.json +6 -0
- package/test-fixtures/mergeRelatorTermFields/fixer/02/record.json +23 -0
- package/test-fixtures/mergeRelatorTermFields/validator/01/expectedResult.json +6 -0
- package/test-fixtures/mergeRelatorTermFields/validator/01/metadata.json +6 -0
- package/test-fixtures/mergeRelatorTermFields/validator/01/record.json +16 -0
- package/test-fixtures/mergeRelatorTermFields/validator/02/expectedResult.json +4 -0
- package/test-fixtures/mergeRelatorTermFields/validator/02/metadata.json +6 -0
- package/test-fixtures/mergeRelatorTermFields/validator/02/record.json +16 -0
- package/test-fixtures/non-breaking-space/01/expectedResult.json +4 -0
- package/test-fixtures/non-breaking-space/01/metadata.json +6 -0
- package/test-fixtures/non-breaking-space/01/record.json +15 -0
- package/test-fixtures/non-breaking-space/02/expectedResult.json +4 -0
- package/test-fixtures/non-breaking-space/02/metadata.json +6 -0
- package/test-fixtures/non-breaking-space/02/record.json +15 -0
- package/test-fixtures/non-breaking-space/03/expectedResult.json +17 -0
- package/test-fixtures/non-breaking-space/03/metadata.json +6 -0
- package/test-fixtures/non-breaking-space/03/record.json +15 -0
- package/test-fixtures/non-breaking-space/04/expectedResult.json +21 -0
- package/test-fixtures/non-breaking-space/04/metadata.json +6 -0
- package/test-fixtures/non-breaking-space/04/record.json +19 -0
- package/test-fixtures/normalize-identifiers/01/expectedResult.json +8 -0
- package/test-fixtures/normalize-identifiers/01/metadata.json +5 -0
- package/test-fixtures/normalize-identifiers/01/record.json +81 -0
- package/test-fixtures/normalize-identifiers/02/expectedResult.json +92 -0
- package/test-fixtures/normalize-identifiers/02/metadata.json +5 -0
- package/test-fixtures/normalize-identifiers/02/record.json +92 -0
- package/test-fixtures/normalize-identifiers/03/expectedResult.json +63 -0
- package/test-fixtures/normalize-identifiers/03/metadata.json +5 -0
- package/test-fixtures/normalize-identifiers/03/record.json +61 -0
- package/test-fixtures/normalize-identifiers/04/expectedResult.json +79 -0
- package/test-fixtures/normalize-identifiers/04/metadata.json +5 -0
- package/test-fixtures/normalize-identifiers/04/record.json +77 -0
- package/test-fixtures/normalize-utf8-diacritics/01/expectedResult.json +7 -0
- package/test-fixtures/normalize-utf8-diacritics/01/metadata.json +5 -0
- package/test-fixtures/normalize-utf8-diacritics/01/record.json +39 -0
- package/test-fixtures/normalize-utf8-diacritics/02/expectedResult.json +41 -0
- package/test-fixtures/normalize-utf8-diacritics/02/metadata.json +5 -0
- package/test-fixtures/normalize-utf8-diacritics/02/record.json +39 -0
- package/test-fixtures/normalize-utf8-diacritics/03/expectedResult.json +5 -0
- package/test-fixtures/normalize-utf8-diacritics/03/metadata.json +5 -0
- package/test-fixtures/normalize-utf8-diacritics/03/record.json +37 -0
- package/test-fixtures/normalize-utf8-diacritics/04/expectedResult.json +41 -0
- package/test-fixtures/normalize-utf8-diacritics/04/metadata.json +5 -0
- package/test-fixtures/normalize-utf8-diacritics/04/record.json +39 -0
- package/test-fixtures/normalize-utf8-diacritics/05/expectedResult.json +41 -0
- package/test-fixtures/normalize-utf8-diacritics/05/metadata.json +5 -0
- package/test-fixtures/normalize-utf8-diacritics/05/record.json +41 -0
- package/test-fixtures/punctuation/01/expectedResult.json +3 -0
- package/test-fixtures/punctuation/01/metadata.json +4 -0
- package/test-fixtures/punctuation/01/record.json +18 -0
- package/test-fixtures/punctuation/02/expectedResult.json +3 -0
- package/test-fixtures/punctuation/02/metadata.json +4 -0
- package/test-fixtures/punctuation/02/record.json +18 -0
- package/test-fixtures/punctuation/03/expectedResult.json +21 -0
- package/test-fixtures/punctuation/03/metadata.json +5 -0
- package/test-fixtures/punctuation/03/record.json +19 -0
- package/test-fixtures/punctuation/04/expectedResult.json +21 -0
- package/test-fixtures/punctuation/04/metadata.json +5 -0
- package/test-fixtures/punctuation/04/record.json +19 -0
- package/test-fixtures/punctuation/05/expectedResult.json +44 -0
- package/test-fixtures/punctuation/05/metadata.json +5 -0
- package/test-fixtures/punctuation/05/record.json +42 -0
- package/test-fixtures/punctuation2/01/expectedResult.json +12 -0
- package/test-fixtures/punctuation2/01/metadata.json +6 -0
- package/test-fixtures/punctuation2/01/record.json +37 -0
- package/test-fixtures/punctuation2/02/expectedResult.json +4 -0
- package/test-fixtures/punctuation2/02/metadata.json +6 -0
- package/test-fixtures/punctuation2/02/record.json +14 -0
- package/test-fixtures/punctuation2/04/expectedResult.json +7 -0
- package/test-fixtures/punctuation2/04/metadata.json +6 -0
- package/test-fixtures/punctuation2/04/record.json +22 -0
- package/test-fixtures/punctuation2/05/expectedResult.json +6 -0
- package/test-fixtures/punctuation2/05/metadata.json +6 -0
- package/test-fixtures/punctuation2/05/record.json +12 -0
- package/test-fixtures/punctuation2/98/expectedResult.json +45 -0
- package/test-fixtures/punctuation2/98/metadata.json +6 -0
- package/test-fixtures/punctuation2/98/record.json +43 -0
- package/test-fixtures/punctuation2/99/expectedResult.json +15 -0
- package/test-fixtures/punctuation2/99/metadata.json +6 -0
- package/test-fixtures/punctuation2/99/record.json +14 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f01/expectedResult.json +35 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f01/metadata.json +6 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f01/record.json +34 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f02/expectedResult.json +53 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f02/metadata.json +6 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f02/record.json +51 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f03/expectedResult.json +46 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f03/metadata.json +7 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/f03/record.json +44 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v01/expectedResult.json +6 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v01/metadata.json +5 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v01/record.json +31 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v02/expectedResult.json +6 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v02/metadata.json +6 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v02/record.json +38 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v03/expectedResult.json +6 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v03/metadata.json +6 -0
- package/test-fixtures/reindex-sf6-occurence-numbers/v03/record.json +30 -0
- package/test-fixtures/remove-duplicate-datafields/f01/expectedResult.json +35 -0
- package/test-fixtures/remove-duplicate-datafields/f01/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f01/record.json +34 -0
- package/test-fixtures/remove-duplicate-datafields/f03/expectedResult.json +20 -0
- package/test-fixtures/remove-duplicate-datafields/f03/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f03/record.json +33 -0
- package/test-fixtures/remove-duplicate-datafields/f03b/expectedResult.json +20 -0
- package/test-fixtures/remove-duplicate-datafields/f03b/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f03b/record.json +35 -0
- package/test-fixtures/remove-duplicate-datafields/f03c/expectedResult.json +25 -0
- package/test-fixtures/remove-duplicate-datafields/f03c/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f03c/record.json +43 -0
- package/test-fixtures/remove-duplicate-datafields/f04/expectedResult.json +31 -0
- package/test-fixtures/remove-duplicate-datafields/f04/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f04/record.json +41 -0
- package/test-fixtures/remove-duplicate-datafields/f05/expectedResult.json +23 -0
- package/test-fixtures/remove-duplicate-datafields/f05/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f05/record.json +29 -0
- package/test-fixtures/remove-duplicate-datafields/f06/expectedResult.json +24 -0
- package/test-fixtures/remove-duplicate-datafields/f06/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f06/record.json +41 -0
- package/test-fixtures/remove-duplicate-datafields/f07/expectedResult.json +15 -0
- package/test-fixtures/remove-duplicate-datafields/f07/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f07/record.json +21 -0
- package/test-fixtures/remove-duplicate-datafields/f08/expectedResult.json +21 -0
- package/test-fixtures/remove-duplicate-datafields/f08/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f08/record.json +33 -0
- package/test-fixtures/remove-duplicate-datafields/f09/expectedResult.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f09/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f09/record.json +9 -0
- package/test-fixtures/remove-duplicate-datafields/f10/expectedResult.json +15 -0
- package/test-fixtures/remove-duplicate-datafields/f10/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f10/record.json +24 -0
- package/test-fixtures/remove-duplicate-datafields/f11/expectedResult.json +30 -0
- package/test-fixtures/remove-duplicate-datafields/f11/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/f11/record.json +53 -0
- package/test-fixtures/remove-duplicate-datafields/v01/expectedResult.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/v01/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/v01/record.json +31 -0
- package/test-fixtures/remove-duplicate-datafields/v02/expectedResult.json +10 -0
- package/test-fixtures/remove-duplicate-datafields/v02/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/v02/record.json +45 -0
- package/test-fixtures/remove-duplicate-datafields/v03/expectedResult.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/v03/metadata.json +7 -0
- package/test-fixtures/remove-duplicate-datafields/v03/record.json +37 -0
- package/test-fixtures/remove-duplicate-datafields/v04/expectedResult.json +8 -0
- package/test-fixtures/remove-duplicate-datafields/v04/metadata.json +6 -0
- package/test-fixtures/remove-duplicate-datafields/v04/record.json +41 -0
- package/test-fixtures/remove-inferior-datafields/f01/expectedResult.json +21 -0
- package/test-fixtures/remove-inferior-datafields/f01/metadata.json +6 -0
- package/test-fixtures/remove-inferior-datafields/f01/record.json +31 -0
- package/test-fixtures/remove-inferior-datafields/f03/expectedResult.json +16 -0
- package/test-fixtures/remove-inferior-datafields/f03/metadata.json +6 -0
- package/test-fixtures/remove-inferior-datafields/f03/record.json +27 -0
- package/test-fixtures/remove-inferior-datafields/f04/expectedResult.json +31 -0
- package/test-fixtures/remove-inferior-datafields/f04/metadata.json +6 -0
- package/test-fixtures/remove-inferior-datafields/f04/record.json +38 -0
- package/test-fixtures/remove-inferior-datafields/f05/expectedResult.json +34 -0
- package/test-fixtures/remove-inferior-datafields/f05/metadata.json +6 -0
- package/test-fixtures/remove-inferior-datafields/f05/record.json +41 -0
- package/test-fixtures/remove-inferior-datafields/f06/expectedResult.json +16 -0
- package/test-fixtures/remove-inferior-datafields/f06/metadata.json +6 -0
- package/test-fixtures/remove-inferior-datafields/f06/record.json +20 -0
- package/test-fixtures/remove-inferior-datafields/v01/expectedResult.json +6 -0
- package/test-fixtures/remove-inferior-datafields/v01/metadata.json +6 -0
- package/test-fixtures/remove-inferior-datafields/v01/record.json +31 -0
- package/test-fixtures/remove-inferior-datafields/v02/expectedResult.json +6 -0
- package/test-fixtures/remove-inferior-datafields/v02/metadata.json +6 -0
- package/test-fixtures/remove-inferior-datafields/v02/record.json +21 -0
- package/test-fixtures/remove-orphanded-sf6s/f01/expectedResult.json +35 -0
- package/test-fixtures/remove-orphanded-sf6s/f01/metadata.json +6 -0
- package/test-fixtures/remove-orphanded-sf6s/f01/record.json +34 -0
- package/test-fixtures/remove-orphanded-sf6s/f02/expectedResult.json +40 -0
- package/test-fixtures/remove-orphanded-sf6s/f02/metadata.json +6 -0
- package/test-fixtures/remove-orphanded-sf6s/f02/record.json +43 -0
- package/test-fixtures/remove-orphanded-sf6s/v01/expectedResult.json +6 -0
- package/test-fixtures/remove-orphanded-sf6s/v01/metadata.json +6 -0
- package/test-fixtures/remove-orphanded-sf6s/v01/record.json +31 -0
- package/test-fixtures/remove-orphanded-sf6s/v02/expectedResult.json +6 -0
- package/test-fixtures/remove-orphanded-sf6s/v02/metadata.json +6 -0
- package/test-fixtures/remove-orphanded-sf6s/v02/record.json +31 -0
- package/test-fixtures/resolvable-ext-references-melinda.js +0 -27
- package/test-fixtures/sanitize-vocabulary-source-codes/f01/expectedResult.json +32 -0
- package/test-fixtures/sanitize-vocabulary-source-codes/f01/metadata.json +6 -0
- package/test-fixtures/sanitize-vocabulary-source-codes/f01/record.json +32 -0
- package/test-fixtures/sanitize-vocabulary-source-codes/f02/expectedResult.json +24 -0
- package/test-fixtures/sanitize-vocabulary-source-codes/f02/metadata.json +6 -0
- package/test-fixtures/sanitize-vocabulary-source-codes/f02/record.json +24 -0
- package/test-fixtures/sanitize-vocabulary-source-codes/v01/expectedResult.json +12 -0
- package/test-fixtures/sanitize-vocabulary-source-codes/v01/metadata.json +6 -0
- package/test-fixtures/sanitize-vocabulary-source-codes/v01/record.json +24 -0
- package/test-fixtures/sort-relator-terms/f01/expectedResult.json +23 -0
- package/test-fixtures/sort-relator-terms/f01/metadata.json +6 -0
- package/test-fixtures/sort-relator-terms/f01/record.json +22 -0
- package/test-fixtures/sort-relator-terms/f02/expectedResult.json +26 -0
- package/test-fixtures/sort-relator-terms/f02/metadata.json +6 -0
- package/test-fixtures/sort-relator-terms/f02/record.json +22 -0
- package/test-fixtures/sort-relator-terms/v01/expectedResult.json +5 -0
- package/test-fixtures/sort-relator-terms/v01/metadata.json +6 -0
- package/test-fixtures/sort-relator-terms/v01/record.json +22 -0
- package/test-fixtures/sort-relator-terms/v02/expectedResult.json +6 -0
- package/test-fixtures/sort-relator-terms/v02/metadata.json +6 -0
- package/test-fixtures/sort-relator-terms/v02/record.json +14 -0
- package/test-fixtures/sort-subfields/f01/expectedResult.json +24 -0
- package/test-fixtures/sort-subfields/f01/metadata.json +6 -0
- package/test-fixtures/sort-subfields/f01/record.json +20 -0
- package/test-fixtures/sort-subfields/v01/expectedResult.json +5 -0
- package/test-fixtures/sort-subfields/v01/metadata.json +6 -0
- package/test-fixtures/sort-subfields/v01/record.json +24 -0
- package/test-fixtures/sort-subfields/v02/expectedResult.json +6 -0
- package/test-fixtures/sort-subfields/v02/metadata.json +6 -0
- package/test-fixtures/sort-subfields/v02/record.json +8 -0
- package/test-fixtures/strip-punctuation/01/expectedResult.json +12 -0
- package/test-fixtures/strip-punctuation/01/metadata.json +6 -0
- package/test-fixtures/strip-punctuation/01/record.json +37 -0
- package/test-fixtures/strip-punctuation/02/expectedResult.json +4 -0
- package/test-fixtures/strip-punctuation/02/metadata.json +6 -0
- package/test-fixtures/strip-punctuation/02/record.json +14 -0
- package/test-fixtures/strip-punctuation/04/expectedResult.json +6 -0
- package/test-fixtures/strip-punctuation/04/metadata.json +6 -0
- package/test-fixtures/strip-punctuation/04/record.json +22 -0
- package/test-fixtures/strip-punctuation/05/expectedResult.json +6 -0
- package/test-fixtures/strip-punctuation/05/metadata.json +6 -0
- package/test-fixtures/strip-punctuation/05/record.json +12 -0
- package/test-fixtures/strip-punctuation/98/expectedResult.json +44 -0
- package/test-fixtures/strip-punctuation/98/metadata.json +6 -0
- package/test-fixtures/strip-punctuation/98/record.json +45 -0
- package/test-fixtures/strip-punctuation/99/expectedResult.json +16 -0
- package/test-fixtures/strip-punctuation/99/metadata.json +6 -0
- package/test-fixtures/strip-punctuation/99/record.json +16 -0
- package/test-fixtures/subfield0/f01/expectedResult.json +25 -0
- package/test-fixtures/subfield0/f01/metadata.json +6 -0
- package/test-fixtures/subfield0/f01/record.json +23 -0
- package/test-fixtures/subfield0/f02/expectedResult.json +35 -0
- package/test-fixtures/subfield0/f02/metadata.json +6 -0
- package/test-fixtures/subfield0/f02/record.json +41 -0
- package/test-fixtures/subfield0/f03/expectedResult.json +21 -0
- package/test-fixtures/subfield0/f03/metadata.json +7 -0
- package/test-fixtures/subfield0/f03/record.json +24 -0
- package/test-fixtures/subfield0/v01/expectedResult.json +4 -0
- package/test-fixtures/subfield0/v01/metadata.json +6 -0
- package/test-fixtures/subfield0/v01/record.json +23 -0
- package/test-fixtures/subfield0/v02/expectedResult.json +9 -0
- package/test-fixtures/subfield0/v02/metadata.json +6 -0
- package/test-fixtures/subfield0/v02/record.json +38 -0
- package/test-fixtures/typeOfDate-008/01/expectedResult.json +3 -0
- package/test-fixtures/typeOfDate-008/01/metadata.json +4 -0
- package/test-fixtures/typeOfDate-008/01/record.json +14 -0
- package/test-fixtures/typeOfDate-008/02/expectedResult.json +4 -0
- package/test-fixtures/typeOfDate-008/02/metadata.json +4 -0
- package/test-fixtures/typeOfDate-008/02/record.json +14 -0
- package/test-fixtures/typeOfDate-008/03/expectedResult.json +14 -0
- package/test-fixtures/typeOfDate-008/03/metadata.json +5 -0
- package/test-fixtures/typeOfDate-008/03/record.json +14 -0
- package/test-fixtures/typeOfDate-008/04/expectedResult.json +14 -0
- package/test-fixtures/typeOfDate-008/04/metadata.json +5 -0
- package/test-fixtures/typeOfDate-008/04/record.json +14 -0
- package/test-fixtures/typeOfDate-008/05/expectedResult.json +14 -0
- package/test-fixtures/typeOfDate-008/05/metadata.json +5 -0
- package/test-fixtures/typeOfDate-008/05/record.json +14 -0
- package/test-fixtures/update-field-540/f01/expectedResult.json +23 -0
- package/test-fixtures/update-field-540/f01/metadata.json +6 -0
- package/test-fixtures/update-field-540/f01/record.json +23 -0
- package/test-fixtures/update-field-540/v01/expectedResult.json +7 -0
- package/test-fixtures/update-field-540/v01/metadata.json +6 -0
- package/test-fixtures/update-field-540/v01/record.json +23 -0
- package/.travis.yml +0 -10
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* MARC record validators used in Melinda
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2014-2018 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of marc-record-validators-melinda
|
|
10
|
-
*
|
|
11
|
-
* marc-record-validators-melinda program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Affero General Public License as
|
|
13
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
14
|
-
* License, or (at your option) any later version.
|
|
15
|
-
*
|
|
16
|
-
* marc-record-validators-melinda is distributed in the hope that it will be useful,
|
|
17
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
-
* GNU Affero General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
22
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
*
|
|
24
|
-
* @licend The above is the entire license notice
|
|
25
|
-
* for the JavaScript code in this file.
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/* eslint-disable no-undef, max-nested-callbacks, no-unused-expressions */
|
|
30
|
-
|
|
31
|
-
'use strict';
|
|
32
|
-
|
|
33
1
|
import chai from 'chai';
|
|
34
2
|
import chaiAsPromised from 'chai-as-promised';
|
|
35
3
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
@@ -40,453 +8,887 @@ chai.use(chaiAsPromised);
|
|
|
40
8
|
|
|
41
9
|
// Factory validation
|
|
42
10
|
describe('field-exclusion', () => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
11
|
+
describe('#validate: Check configuration validation', () => {
|
|
12
|
+
it('Creates a validator from simple config', async () => {
|
|
13
|
+
const config = [/^500$/u];
|
|
14
|
+
|
|
15
|
+
const validator = await validatorFactory(config);
|
|
16
|
+
expect(validator)
|
|
17
|
+
.to.be.an('object')
|
|
18
|
+
.that.has.any.keys('description', 'validate');
|
|
19
|
+
|
|
20
|
+
expect(validator.description).to.be.a('string');
|
|
21
|
+
expect(validator.validate).to.be.a('function');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('Creates a validator from complex config', async () => {
|
|
25
|
+
const config = [
|
|
26
|
+
{
|
|
27
|
+
tag: /^500$/u,
|
|
28
|
+
subfields: [{code: /9/u, value: /^(?!FENNI<KEEP>).*$/u}]
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const validator = await validatorFactory(config);
|
|
33
|
+
expect(validator)
|
|
34
|
+
.to.be.an('object')
|
|
35
|
+
.that.has.any.keys('description', 'validate');
|
|
36
|
+
|
|
37
|
+
expect(validator.description).to.be.a('string');
|
|
38
|
+
expect(validator.validate).to.be.a('function');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('Fails to create a validator from invalid config - tag', async () => {
|
|
42
|
+
const config = [
|
|
43
|
+
{
|
|
44
|
+
tag: '500',
|
|
45
|
+
subfields: [{code: /9/u, value: /^(?!FENNI<KEEP>).*$/u}]
|
|
46
|
+
}
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
await validatorFactory(config);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
expect(error).to.be.an('error').with.property('message', 'Configuration not valid - invalid data type for: tag');
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('Fails to create a validator from invalid config - msising array', async () => {
|
|
57
|
+
const config = {
|
|
58
|
+
tag: '500',
|
|
59
|
+
subfields: [{code: /9/u, value: /^(?!FENNI<KEEP>).*$/u}]
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
await validatorFactory(config);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
expect(error).to.be.an('error').with.property('message', 'Configuration array not provided');
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('Fails to create a validator from invalid config - code', async () => {
|
|
70
|
+
const config = [
|
|
71
|
+
{
|
|
72
|
+
tag: /^500$/u,
|
|
73
|
+
subfields: [{code: 9, value: /^(?!FENNI<KEEP>).*$/u}]
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
await validatorFactory(config);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
expect(error).to.be.an('error').with.property('message', 'Configuration not valid - invalid data type for: code');
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('Fails to create a validator from invalid config - value', async () => {
|
|
85
|
+
const config = [
|
|
86
|
+
{
|
|
87
|
+
tag: /^500$/u,
|
|
88
|
+
subfields: [{code: /9/u, value: 'Fenni'}]
|
|
89
|
+
}
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
await validatorFactory(config);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
expect(error).to.be.an('error').with.property('message', 'Configuration not valid - invalid data type for: value');
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('Fails to create a validator from invalid config - exclusion: value, ind1', async () => {
|
|
100
|
+
const config = [
|
|
101
|
+
{
|
|
102
|
+
tag: /^500$/u,
|
|
103
|
+
value: /^500$/u,
|
|
104
|
+
ind1: /^500$/u,
|
|
105
|
+
subfields: [{code: /9/u, value: /^(?!FENNI<KEEP>).*$/u}]
|
|
106
|
+
}
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
await validatorFactory(config);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
expect(error).to.be.an('error').with.property('message', 'Configuration not valid - excluded element');
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('Fails to create a validator from invalid config - missing mandatory: tag', async () => {
|
|
117
|
+
const config = [
|
|
118
|
+
{
|
|
119
|
+
value: /^500$/u,
|
|
120
|
+
subfields: [{code: /9/u, value: /^(?!FENNI<KEEP>).*$/u}]
|
|
121
|
+
}
|
|
122
|
+
];
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
await validatorFactory(config);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
expect(error).to.be.an('error').with.property('message', 'Configuration not valid - missing mandatory element: tag');
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('Fails to create a validator from invalid config - subfield not object: array', async () => {
|
|
132
|
+
const config = [
|
|
133
|
+
{
|
|
134
|
+
tag: /^500$/u,
|
|
135
|
+
subfields: [
|
|
136
|
+
['/9/', '/^(?!FENNI<KEEP>).*$/'],
|
|
137
|
+
{value: /^(?!FENNI<KEEP>).*$/u}
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
await validatorFactory(config);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
expect(error).to.be.an('error').with.property('message', 'Configuration not valid - subfield: /9/,/^(?!FENNI<KEEP>).*$/ not object');
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('Fails to create a validator from invalid config - subfield not object: string', async () => {
|
|
150
|
+
const config = [
|
|
151
|
+
{
|
|
152
|
+
tag: /^500$/u,
|
|
153
|
+
subfields: [
|
|
154
|
+
'/9/',
|
|
155
|
+
'/^(?!FENNI<KEEP>).*$/',
|
|
156
|
+
{value: /^(?!FENNI<KEEP>).*$/u}
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
try {
|
|
162
|
+
await validatorFactory(config);
|
|
163
|
+
} catch (error) {
|
|
164
|
+
expect(error).to.be.an('error').with.property('message', 'Configuration not valid - subfield: /9/ not object');
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('Fails to create a validator from invalid config - missing mandatory: subfield.code', async () => {
|
|
169
|
+
const config = [
|
|
170
|
+
{
|
|
171
|
+
tag: /^500$/u,
|
|
172
|
+
subfields: [
|
|
173
|
+
{code: /9/u, value: /^(?!FENNI<KEEP>).*$/u},
|
|
174
|
+
{value: /^(?!FENNI<KEEP>).*$/u}
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
];
|
|
178
|
+
|
|
179
|
+
try {
|
|
180
|
+
await validatorFactory(config);
|
|
181
|
+
} catch (error) {
|
|
182
|
+
expect(error).to.be.an('error').with.property('message', 'Configuration not valid - missing mandatory element: code');
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('Fails to create a validator from invalid config - unidentified field: unidentified', async () => {
|
|
187
|
+
const config = [
|
|
188
|
+
{
|
|
189
|
+
tag: /^500$/u,
|
|
190
|
+
unidentified: /^500$/u,
|
|
191
|
+
subfields: [
|
|
192
|
+
{code: /9/u, value: /^(?!FENNI<KEEP>).*$/u},
|
|
193
|
+
{value: /^(?!FENNI<KEEP>).*$/u}
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
];
|
|
197
|
+
|
|
198
|
+
try {
|
|
199
|
+
await validatorFactory(config);
|
|
200
|
+
} catch (error) {
|
|
201
|
+
expect(error).to.be.an('error').with.property('message', 'Configuration not valid - unidentified value: unidentified');
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// Simple configuration https://github.com/NatLibFi/marc-record-validators-melinda/issues/45
|
|
207
|
+
describe('#validate: Simple configuration (spec)', () => {
|
|
208
|
+
const config = [
|
|
209
|
+
{
|
|
210
|
+
tag: /^500$/u
|
|
211
|
+
}
|
|
212
|
+
];
|
|
213
|
+
|
|
214
|
+
const recordValid = new MarcRecord({
|
|
215
|
+
leader: 'foo',
|
|
216
|
+
fields: [
|
|
217
|
+
{
|
|
218
|
+
tag: '245',
|
|
219
|
+
ind1: ' ',
|
|
220
|
+
ind2: ' ',
|
|
221
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const recordInvalid = new MarcRecord({
|
|
227
|
+
leader: 'foo',
|
|
228
|
+
fields: [
|
|
229
|
+
{
|
|
230
|
+
tag: '245',
|
|
231
|
+
ind1: ' ',
|
|
232
|
+
ind2: ' ',
|
|
233
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
234
|
+
}, {
|
|
235
|
+
tag: '500',
|
|
236
|
+
ind1: ' ',
|
|
237
|
+
ind2: ' ',
|
|
238
|
+
subfields: [
|
|
239
|
+
{code: 'a', value: 'Foo Bar Foo Bar Foo Bar'},
|
|
240
|
+
{code: '9', value: 'ALMA<KEEP>'}
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
const recordInvalidDouble = new MarcRecord({
|
|
247
|
+
leader: 'foo',
|
|
248
|
+
fields: [
|
|
249
|
+
{
|
|
250
|
+
tag: '245',
|
|
251
|
+
ind1: ' ',
|
|
252
|
+
ind2: ' ',
|
|
253
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
254
|
+
}, {
|
|
255
|
+
tag: '500',
|
|
256
|
+
ind1: ' ',
|
|
257
|
+
ind2: ' ',
|
|
258
|
+
subfields: [
|
|
259
|
+
{code: 'a', value: 'Foo'},
|
|
260
|
+
{code: '9', value: 'ALMA<KEEP>'}
|
|
261
|
+
]
|
|
262
|
+
}, {
|
|
263
|
+
tag: '500',
|
|
264
|
+
ind1: ' ',
|
|
265
|
+
ind2: ' ',
|
|
266
|
+
subfields: [
|
|
267
|
+
{code: 'a', value: 'Bar'},
|
|
268
|
+
{code: '9', value: 'ALMA<KEEP>'}
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
const recordInvalidFixed = new MarcRecord({
|
|
275
|
+
leader: 'foo',
|
|
276
|
+
fields: [
|
|
277
|
+
{
|
|
278
|
+
tag: '245',
|
|
279
|
+
ind1: ' ',
|
|
280
|
+
ind2: ' ',
|
|
281
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
282
|
+
}
|
|
283
|
+
]
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('Finds the record valid (spec)', async () => {
|
|
287
|
+
const validator = await validatorFactory(config);
|
|
288
|
+
const {valid, message} = await validator.validate(recordValid);
|
|
289
|
+
expect({valid, message}).to.eql({valid: true, message: []});
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('Finds the record invalid (spec)', async () => {
|
|
293
|
+
const validator = await validatorFactory(config);
|
|
294
|
+
const {valid, message} = await validator.validate(recordInvalid);
|
|
295
|
+
expect({valid, message}).to.eql({valid: false, message: ['Field $500 should be excluded']});
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('Finds the record invalid - double', async () => {
|
|
299
|
+
const validator = await validatorFactory(config);
|
|
300
|
+
const {valid, message} = await validator.validate(recordInvalidDouble);
|
|
301
|
+
expect({valid, message}).to.eql({valid: false, message: ['Field $500 should be excluded', 'Field $500 should be excluded']});
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it('Repairs invalid record', async () => {
|
|
305
|
+
const validator = await validatorFactory(config);
|
|
306
|
+
await validator.fix(recordInvalid);
|
|
307
|
+
expect(recordInvalid.equalsTo(recordInvalidFixed)).to.eql(true);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it('Repairs invalid record - double', async () => {
|
|
311
|
+
const validator = await validatorFactory(config);
|
|
312
|
+
await validator.fix(recordInvalidDouble);
|
|
313
|
+
expect(recordInvalidDouble.equalsTo(recordInvalidFixed)).to.eql(true);
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
// Simple multi tag configuration
|
|
318
|
+
describe('#validate: Simple multi tag configuration (spec)', () => {
|
|
319
|
+
const config = [
|
|
320
|
+
{
|
|
321
|
+
tag: /^(648|650|651|655)$/u // eslint-disable-line prefer-named-capture-group
|
|
322
|
+
}
|
|
323
|
+
];
|
|
324
|
+
|
|
325
|
+
const recordValid = new MarcRecord({
|
|
326
|
+
leader: 'foo',
|
|
327
|
+
fields: [
|
|
328
|
+
{
|
|
329
|
+
tag: '245',
|
|
330
|
+
ind1: ' ',
|
|
331
|
+
ind2: ' ',
|
|
332
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
333
|
+
}
|
|
334
|
+
]
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
const recordInvalid = new MarcRecord({
|
|
338
|
+
leader: 'foo',
|
|
339
|
+
fields: [
|
|
340
|
+
{
|
|
341
|
+
tag: '245',
|
|
342
|
+
ind1: ' ',
|
|
343
|
+
ind2: ' ',
|
|
344
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
345
|
+
}, {
|
|
346
|
+
tag: '648',
|
|
347
|
+
ind1: ' ',
|
|
348
|
+
ind2: ' ',
|
|
349
|
+
subfields: [
|
|
350
|
+
{code: 'a', value: 'Foo Bar Foo Bar Foo Bar'},
|
|
351
|
+
{code: '9', value: 'ALMA<KEEP>'}
|
|
352
|
+
]
|
|
353
|
+
}
|
|
354
|
+
]
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
const recordInvalidDouble = new MarcRecord({
|
|
358
|
+
leader: 'foo',
|
|
359
|
+
fields: [
|
|
360
|
+
{
|
|
361
|
+
tag: '245',
|
|
362
|
+
ind1: ' ',
|
|
363
|
+
ind2: ' ',
|
|
364
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
365
|
+
}, {
|
|
366
|
+
tag: '648',
|
|
367
|
+
ind1: ' ',
|
|
368
|
+
ind2: ' ',
|
|
369
|
+
subfields: [
|
|
370
|
+
{code: 'a', value: 'Foo'},
|
|
371
|
+
{code: '9', value: 'ALMA<KEEP>'}
|
|
372
|
+
]
|
|
373
|
+
}, {
|
|
374
|
+
tag: '650',
|
|
375
|
+
ind1: ' ',
|
|
376
|
+
ind2: ' ',
|
|
377
|
+
subfields: [
|
|
378
|
+
{code: 'a', value: 'Bar'},
|
|
379
|
+
{code: '9', value: 'ALMA<KEEP>'}
|
|
380
|
+
]
|
|
381
|
+
}
|
|
382
|
+
]
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
const recordInvalidFixed = new MarcRecord({
|
|
386
|
+
leader: 'foo',
|
|
387
|
+
fields: [
|
|
388
|
+
{
|
|
389
|
+
tag: '245',
|
|
390
|
+
ind1: ' ',
|
|
391
|
+
ind2: ' ',
|
|
392
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
393
|
+
}
|
|
394
|
+
]
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
it('Finds the record valid (spec)', async () => {
|
|
398
|
+
const validator = await validatorFactory(config);
|
|
399
|
+
const {valid, message} = await validator.validate(recordValid);
|
|
400
|
+
expect({valid, message}).to.eql({valid: true, message: []});
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
it('Finds the record invalid (spec)', async () => {
|
|
404
|
+
const validator = await validatorFactory(config);
|
|
405
|
+
const {valid, message} = await validator.validate(recordInvalid);
|
|
406
|
+
expect({valid, message}).to.eql({valid: false, message: ['Field $648 should be excluded']});
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
it('Finds the record invalid - double', async () => {
|
|
410
|
+
const validator = await validatorFactory(config);
|
|
411
|
+
const {valid, message} = await validator.validate(recordInvalidDouble);
|
|
412
|
+
expect({valid, message}).to.eql({valid: false, message: ['Field $648 should be excluded', 'Field $650 should be excluded']});
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
it('Repairs invalid record', async () => {
|
|
416
|
+
const validator = await validatorFactory(config);
|
|
417
|
+
await validator.fix(recordInvalid);
|
|
418
|
+
expect(recordInvalid.equalsTo(recordInvalidFixed)).to.eql(true);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
it('Repairs invalid record - double', async () => {
|
|
422
|
+
const validator = await validatorFactory(config);
|
|
423
|
+
await validator.fix(recordInvalidDouble);
|
|
424
|
+
expect(recordInvalidDouble.equalsTo(recordInvalidFixed)).to.eql(true);
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
// Simple multi tag configuration
|
|
429
|
+
describe('#validate: Simple multi tag configuration - No object (spec)', () => {
|
|
430
|
+
const config = [/^(648|650|651|655)$/u]; // eslint-disable-line prefer-named-capture-group
|
|
431
|
+
|
|
432
|
+
const recordValid = new MarcRecord({
|
|
433
|
+
leader: 'foo',
|
|
434
|
+
fields: [
|
|
435
|
+
{
|
|
436
|
+
tag: '245',
|
|
437
|
+
ind1: ' ',
|
|
438
|
+
ind2: ' ',
|
|
439
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
440
|
+
}
|
|
441
|
+
]
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
const recordInvalid = new MarcRecord({
|
|
445
|
+
leader: 'foo',
|
|
446
|
+
fields: [
|
|
447
|
+
{
|
|
448
|
+
tag: '245',
|
|
449
|
+
ind1: ' ',
|
|
450
|
+
ind2: ' ',
|
|
451
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
452
|
+
}, {
|
|
453
|
+
tag: '648',
|
|
454
|
+
ind1: ' ',
|
|
455
|
+
ind2: ' ',
|
|
456
|
+
subfields: [
|
|
457
|
+
{code: 'a', value: 'Foo Bar Foo Bar Foo Bar'},
|
|
458
|
+
{code: '9', value: 'ALMA<KEEP>'}
|
|
459
|
+
]
|
|
460
|
+
}
|
|
461
|
+
]
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
const recordInvalidDouble = new MarcRecord({
|
|
465
|
+
leader: 'foo',
|
|
466
|
+
fields: [
|
|
467
|
+
{
|
|
468
|
+
tag: '245',
|
|
469
|
+
ind1: ' ',
|
|
470
|
+
ind2: ' ',
|
|
471
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
472
|
+
}, {
|
|
473
|
+
tag: '648',
|
|
474
|
+
ind1: ' ',
|
|
475
|
+
ind2: ' ',
|
|
476
|
+
subfields: [
|
|
477
|
+
{code: 'a', value: 'Foo'},
|
|
478
|
+
{code: '9', value: 'ALMA<KEEP>'}
|
|
479
|
+
]
|
|
480
|
+
}, {
|
|
481
|
+
tag: '650',
|
|
482
|
+
ind1: ' ',
|
|
483
|
+
ind2: ' ',
|
|
484
|
+
subfields: [
|
|
485
|
+
{code: 'a', value: 'Bar'},
|
|
486
|
+
{code: '9', value: 'ALMA<KEEP>'}
|
|
487
|
+
]
|
|
488
|
+
}
|
|
489
|
+
]
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
const recordInvalidFixed = new MarcRecord({
|
|
493
|
+
leader: 'foo',
|
|
494
|
+
fields: [
|
|
495
|
+
{
|
|
496
|
+
tag: '245',
|
|
497
|
+
ind1: ' ',
|
|
498
|
+
ind2: ' ',
|
|
499
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
500
|
+
}
|
|
501
|
+
]
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
it('Finds the record valid (spec)', async () => {
|
|
505
|
+
const validator = await validatorFactory(config);
|
|
506
|
+
const {valid, message} = await validator.validate(recordValid);
|
|
507
|
+
expect({valid, message}).to.eql({valid: true, message: []});
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
it('Finds the record invalid (spec)', async () => {
|
|
511
|
+
const validator = await validatorFactory(config);
|
|
512
|
+
const {valid, message} = await validator.validate(recordInvalid);
|
|
513
|
+
expect({valid, message}).to.eql({valid: false, message: ['Field $648 should be excluded']});
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
it('Finds the record invalid - double', async () => {
|
|
517
|
+
const validator = await validatorFactory(config);
|
|
518
|
+
const {valid, message} = await validator.validate(recordInvalidDouble);
|
|
519
|
+
expect({valid, message}).to.eql({valid: false, message: ['Field $648 should be excluded', 'Field $650 should be excluded']});
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
it('Repairs invalid record', async () => {
|
|
523
|
+
const validator = await validatorFactory(config);
|
|
524
|
+
await validator.fix(recordInvalid);
|
|
525
|
+
expect(recordInvalid.equalsTo(recordInvalidFixed)).to.eql(true);
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
it('Repairs invalid record - double', async () => {
|
|
529
|
+
const validator = await validatorFactory(config);
|
|
530
|
+
await validator.fix(recordInvalidDouble);
|
|
531
|
+
expect(recordInvalidDouble.equalsTo(recordInvalidFixed)).to.eql(true);
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
// Complex configuration https://github.com/NatLibFi/marc-record-validators-melinda/issues/45
|
|
537
|
+
describe('#validate: Complex configuration (spec)', () => {
|
|
538
|
+
const config = [
|
|
539
|
+
{
|
|
540
|
+
tag: /^500$/u,
|
|
541
|
+
subfields: [{code: /9/u, value: /^(?!FENNI<KEEP>).*$/u}]
|
|
542
|
+
}
|
|
543
|
+
];
|
|
544
|
+
|
|
545
|
+
const recordValid = new MarcRecord({
|
|
546
|
+
leader: 'foo',
|
|
547
|
+
fields: [
|
|
548
|
+
{
|
|
549
|
+
tag: '245',
|
|
550
|
+
ind1: ' ',
|
|
551
|
+
ind2: ' ',
|
|
552
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
553
|
+
}, {
|
|
554
|
+
tag: '500',
|
|
555
|
+
ind1: ' ',
|
|
556
|
+
ind2: ' ',
|
|
557
|
+
subfields: [
|
|
558
|
+
{code: 'a', value: 'Foo Bar Foo Bar Foo Bar'},
|
|
559
|
+
{code: '9', value: 'FENNI<KEEP>'}
|
|
560
|
+
]
|
|
561
|
+
}
|
|
562
|
+
]
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
const recordInvalid = new MarcRecord({
|
|
566
|
+
leader: 'foo',
|
|
567
|
+
fields: [
|
|
568
|
+
{
|
|
569
|
+
tag: '245',
|
|
570
|
+
ind1: ' ',
|
|
571
|
+
ind2: ' ',
|
|
572
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
573
|
+
}, {
|
|
574
|
+
tag: '500',
|
|
575
|
+
ind1: ' ',
|
|
576
|
+
ind2: ' ',
|
|
577
|
+
subfields: [
|
|
578
|
+
{code: 'a', value: 'Foo Bar Foo Bar Foo Bar'},
|
|
579
|
+
{code: '9', value: 'ALMA<KEEP>'}
|
|
580
|
+
]
|
|
581
|
+
}
|
|
582
|
+
]
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
const recordInvalidFixed = new MarcRecord({
|
|
586
|
+
leader: 'foo',
|
|
587
|
+
fields: [
|
|
588
|
+
{
|
|
589
|
+
tag: '245',
|
|
590
|
+
ind1: ' ',
|
|
591
|
+
ind2: ' ',
|
|
592
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
593
|
+
}
|
|
594
|
+
]
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
it('Finds the record valid (spec)', async () => {
|
|
598
|
+
const validator = await validatorFactory(config);
|
|
599
|
+
const {valid, message} = await validator.validate(recordValid);
|
|
600
|
+
expect({valid, message}).to.eql({valid: true, message: []});
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
it('Finds the record invalid (spec)', async () => {
|
|
604
|
+
const validator = await validatorFactory(config);
|
|
605
|
+
const {valid, message} = await validator.validate(recordInvalid);
|
|
606
|
+
expect({valid, message}).to.eql({valid: false, message: ['Field $500 should be excluded']});
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
it('Repairs invalid record', async () => {
|
|
610
|
+
const validator = await validatorFactory(config);
|
|
611
|
+
await validator.fix(recordInvalid);
|
|
612
|
+
expect(recordInvalid.equalsTo(recordInvalidFixed)).to.eql(true);
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
// Complex multi tag configuration
|
|
617
|
+
describe('#validate: Complex multi tag configuration (spec)', () => {
|
|
618
|
+
const config = [
|
|
619
|
+
{
|
|
620
|
+
tag: /^(648|650|651|655)$/u, // eslint-disable-line prefer-named-capture-group
|
|
621
|
+
subfields: [{code: /^2$/u, value: /^(ysa|musa|allars|cilla)$/u}] // eslint-disable-line prefer-named-capture-group
|
|
622
|
+
}
|
|
623
|
+
];
|
|
624
|
+
|
|
625
|
+
const recordValid = new MarcRecord({
|
|
626
|
+
leader: 'foo',
|
|
627
|
+
fields: [
|
|
628
|
+
{
|
|
629
|
+
tag: '245',
|
|
630
|
+
ind1: ' ',
|
|
631
|
+
ind2: ' ',
|
|
632
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
633
|
+
}, {
|
|
634
|
+
tag: '650',
|
|
635
|
+
ind1: ' ',
|
|
636
|
+
ind2: ' ',
|
|
637
|
+
subfields: [
|
|
638
|
+
{code: 'a', value: 'Foo Bar Foo Bar Foo Bar'},
|
|
639
|
+
{code: '2', value: 'yso'}
|
|
640
|
+
]
|
|
641
|
+
}
|
|
642
|
+
]
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
const recordInvalid = new MarcRecord({
|
|
646
|
+
leader: 'foo',
|
|
647
|
+
fields: [
|
|
648
|
+
{
|
|
649
|
+
tag: '245',
|
|
650
|
+
ind1: ' ',
|
|
651
|
+
ind2: ' ',
|
|
652
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
653
|
+
}, {
|
|
654
|
+
tag: '650',
|
|
655
|
+
ind1: ' ',
|
|
656
|
+
ind2: ' ',
|
|
657
|
+
subfields: [
|
|
658
|
+
{code: 'a', value: 'Foo Bar Foo Bar Foo Bar'},
|
|
659
|
+
{code: '2', value: 'ysa'}
|
|
660
|
+
]
|
|
661
|
+
}
|
|
662
|
+
]
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
const recordInvalidMulti = new MarcRecord({
|
|
666
|
+
leader: 'foo',
|
|
667
|
+
fields: [
|
|
668
|
+
{
|
|
669
|
+
tag: '245',
|
|
670
|
+
ind1: ' ',
|
|
671
|
+
ind2: ' ',
|
|
672
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
673
|
+
}, {
|
|
674
|
+
tag: '648',
|
|
675
|
+
ind1: ' ',
|
|
676
|
+
ind2: ' ',
|
|
677
|
+
subfields: [{code: '2', value: 'ysa'}]
|
|
678
|
+
}, {
|
|
679
|
+
tag: '650',
|
|
680
|
+
ind1: ' ',
|
|
681
|
+
ind2: ' ',
|
|
682
|
+
subfields: [{code: '2', value: 'ysa'}]
|
|
683
|
+
}, {
|
|
684
|
+
tag: '650',
|
|
685
|
+
ind1: ' ',
|
|
686
|
+
ind2: ' ',
|
|
687
|
+
subfields: [{code: '2', value: 'ysa'}]
|
|
688
|
+
}, {
|
|
689
|
+
tag: '651',
|
|
690
|
+
ind1: ' ',
|
|
691
|
+
ind2: ' ',
|
|
692
|
+
subfields: [{code: '2', value: 'ysa'}]
|
|
693
|
+
}, {
|
|
694
|
+
tag: '655',
|
|
695
|
+
ind1: ' ',
|
|
696
|
+
ind2: ' ',
|
|
697
|
+
subfields: [{code: '2', value: 'ysa'}]
|
|
698
|
+
}
|
|
699
|
+
]
|
|
700
|
+
});
|
|
701
|
+
|
|
702
|
+
const recordInvalidFixed = new MarcRecord({
|
|
703
|
+
leader: 'foo',
|
|
704
|
+
fields: [
|
|
705
|
+
{
|
|
706
|
+
tag: '245',
|
|
707
|
+
ind1: ' ',
|
|
708
|
+
ind2: ' ',
|
|
709
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
710
|
+
}
|
|
711
|
+
]
|
|
712
|
+
});
|
|
713
|
+
|
|
714
|
+
it('Finds the record valid (spec)', async () => {
|
|
715
|
+
const validator = await validatorFactory(config);
|
|
716
|
+
const {valid, message} = await validator.validate(recordValid);
|
|
717
|
+
expect({valid, message}).to.eql({valid: true, message: []});
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
it('Finds the record invalid (spec)', async () => {
|
|
721
|
+
const validator = await validatorFactory(config);
|
|
722
|
+
const {valid, message} = await validator.validate(recordInvalid);
|
|
723
|
+
expect({valid, message}).to.eql({valid: false, message: ['Field $650 should be excluded']});
|
|
724
|
+
});
|
|
725
|
+
|
|
726
|
+
it('Finds the record invalid (spec)', async () => {
|
|
727
|
+
const validator = await validatorFactory(config);
|
|
728
|
+
const {valid, message} = await validator.validate(recordInvalidMulti);
|
|
729
|
+
expect({valid, message}).to.eql({valid: false, message: [
|
|
730
|
+
'Field $648 should be excluded',
|
|
731
|
+
'Field $650 should be excluded',
|
|
732
|
+
'Field $650 should be excluded',
|
|
733
|
+
'Field $651 should be excluded',
|
|
734
|
+
'Field $655 should be excluded'
|
|
735
|
+
]});
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
it('Repairs invalid multi record', async () => {
|
|
739
|
+
const validator = await validatorFactory(config);
|
|
740
|
+
await validator.fix(recordInvalidMulti);
|
|
741
|
+
expect(recordInvalidMulti.equalsTo(recordInvalidFixed)).to.eql(true);
|
|
742
|
+
});
|
|
743
|
+
|
|
744
|
+
it('Repairs invalid record', async () => {
|
|
745
|
+
const validator = await validatorFactory(config);
|
|
746
|
+
await validator.fix(recordInvalid);
|
|
747
|
+
expect(recordInvalid.equalsTo(recordInvalidFixed)).to.eql(true);
|
|
748
|
+
});
|
|
749
|
+
});
|
|
750
|
+
|
|
751
|
+
// More special cases to increase coverage
|
|
752
|
+
describe('#validate: Custom configuration', () => {
|
|
753
|
+
const configInd = [
|
|
754
|
+
{
|
|
755
|
+
tag: /^500$/u,
|
|
756
|
+
ind1: /^8$/u,
|
|
757
|
+
ind2: /^4$/u
|
|
758
|
+
}
|
|
759
|
+
];
|
|
760
|
+
|
|
761
|
+
const configValue = [
|
|
762
|
+
{
|
|
763
|
+
tag: /^500$/u,
|
|
764
|
+
value: /^8$/u
|
|
765
|
+
}
|
|
766
|
+
];
|
|
767
|
+
|
|
768
|
+
const recordValid = new MarcRecord({
|
|
769
|
+
leader: 'foo',
|
|
770
|
+
fields: [
|
|
771
|
+
{
|
|
772
|
+
tag: '500',
|
|
773
|
+
ind1: '8',
|
|
774
|
+
ind2: '0',
|
|
775
|
+
subfields: [
|
|
776
|
+
{code: 'a', value: 'Foo Bar Foo Bar Foo Bar'},
|
|
777
|
+
{code: '9', value: 'ALMA<KEEP>'}
|
|
778
|
+
]
|
|
779
|
+
}
|
|
780
|
+
]
|
|
781
|
+
});
|
|
782
|
+
|
|
783
|
+
const recordIndInvalid = new MarcRecord({
|
|
784
|
+
leader: 'foo',
|
|
785
|
+
fields: [
|
|
786
|
+
{
|
|
787
|
+
tag: '245',
|
|
788
|
+
ind1: ' ',
|
|
789
|
+
ind2: ' ',
|
|
790
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
791
|
+
}, {
|
|
792
|
+
tag: '500',
|
|
793
|
+
ind1: '8',
|
|
794
|
+
ind2: '4',
|
|
795
|
+
subfields: [
|
|
796
|
+
{code: 'a', value: 'Foo Bar Foo Bar Foo Bar'},
|
|
797
|
+
{code: '9', value: 'ALMA<KEEP>'}
|
|
798
|
+
]
|
|
799
|
+
}
|
|
800
|
+
]
|
|
801
|
+
});
|
|
802
|
+
|
|
803
|
+
const recordValueInvalid = new MarcRecord({
|
|
804
|
+
leader: 'foo',
|
|
805
|
+
fields: [
|
|
806
|
+
{
|
|
807
|
+
tag: '245',
|
|
808
|
+
ind1: ' ',
|
|
809
|
+
ind2: ' ',
|
|
810
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
811
|
+
}, {
|
|
812
|
+
tag: '500',
|
|
813
|
+
value: '8'
|
|
814
|
+
}
|
|
815
|
+
]
|
|
816
|
+
});
|
|
817
|
+
|
|
818
|
+
const recordInvalidFixed = new MarcRecord({
|
|
819
|
+
leader: 'foo',
|
|
820
|
+
fields: [
|
|
821
|
+
{
|
|
822
|
+
tag: '245',
|
|
823
|
+
ind1: ' ',
|
|
824
|
+
ind2: ' ',
|
|
825
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
826
|
+
}
|
|
827
|
+
]
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
it('Finds the record valid - Ind1&Ind2', async () => {
|
|
831
|
+
const validator = await validatorFactory(configInd);
|
|
832
|
+
const {valid, message} = await validator.validate(recordValid);
|
|
833
|
+
expect({valid, message}).to.eql({valid: true, message: []});
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
it('Finds the record valid - Value', async () => {
|
|
837
|
+
const validator = await validatorFactory(configValue);
|
|
838
|
+
const {valid, message} = await validator.validate(recordValid);
|
|
839
|
+
expect({valid, message}).to.eql({valid: true, message: []});
|
|
840
|
+
});
|
|
841
|
+
|
|
842
|
+
it('Finds the record invalid - Ind', async () => {
|
|
843
|
+
const validator = await validatorFactory(configInd);
|
|
844
|
+
const {valid, message} = await validator.validate(recordIndInvalid);
|
|
845
|
+
expect({valid, message}).to.eql({valid: false, message: ['Field $500 should be excluded']});
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
it('Finds the record invalid - Value', async () => {
|
|
849
|
+
const validator = await validatorFactory(configValue);
|
|
850
|
+
const {valid, message} = await validator.validate(recordValueInvalid);
|
|
851
|
+
expect({valid, message}).to.eql({valid: false, message: ['Field $500 should be excluded']});
|
|
852
|
+
});
|
|
853
|
+
|
|
854
|
+
it('Repairs invalid record - Ind', async () => {
|
|
855
|
+
const validator = await validatorFactory(configInd);
|
|
856
|
+
await validator.fix(recordIndInvalid);
|
|
857
|
+
expect(recordIndInvalid.equalsTo(recordInvalidFixed)).to.eql(true);
|
|
858
|
+
});
|
|
859
|
+
|
|
860
|
+
it('Repairs invalid record - Value', async () => {
|
|
861
|
+
const validator = await validatorFactory(configValue);
|
|
862
|
+
await validator.fix(recordValueInvalid);
|
|
863
|
+
expect(recordValueInvalid.equalsTo(recordInvalidFixed)).to.eql(true);
|
|
864
|
+
});
|
|
865
|
+
});
|
|
866
|
+
|
|
867
|
+
describe('Dependencies', () => {
|
|
868
|
+
it('Finds the record invalid because dependency matches', async () => {
|
|
869
|
+
const config = [
|
|
870
|
+
{
|
|
871
|
+
tag: /^041$/u,
|
|
872
|
+
dependencies: [{leader: /^.{6}a/u}]
|
|
873
|
+
}
|
|
874
|
+
];
|
|
875
|
+
|
|
876
|
+
const record = new MarcRecord({
|
|
877
|
+
leader: '00000cam^a22003372i^4500',
|
|
878
|
+
fields: [
|
|
879
|
+
{
|
|
880
|
+
tag: '041',
|
|
881
|
+
ind1: ' ',
|
|
882
|
+
ind2: ' ',
|
|
883
|
+
subfields: [{code: 'a', value: 'Fubar'}]
|
|
884
|
+
}
|
|
885
|
+
]
|
|
886
|
+
});
|
|
887
|
+
|
|
888
|
+
const validator = await validatorFactory(config);
|
|
889
|
+
const {valid, message} = await validator.validate(record);
|
|
890
|
+
|
|
891
|
+
expect({valid, message}).to.eql({valid: false, message: ['Field $041 should be excluded']});
|
|
892
|
+
});
|
|
893
|
+
});
|
|
492
894
|
});
|