@natlibfi/marc-record-validators-melinda 3.2.0 → 3.3.14-alpha.3
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,32 +1,522 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _chai = require("chai");
|
|
4
|
+
var _marcRecord = require("@natlibfi/marc-record");
|
|
5
|
+
var _subfieldExclusion = _interopRequireDefault(require("../src/subfield-exclusion"));
|
|
6
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
+
//import chaiAsPromised from 'chai-as-promised';
|
|
8
|
+
|
|
9
|
+
//chai.use(chaiAsPromised);
|
|
10
|
+
// Factory validation
|
|
11
|
+
describe('subfield-exclusion', () => {
|
|
12
|
+
describe('#validate: Check configuration validation', () => {
|
|
13
|
+
it('Creates a validator from simple config', async () => {
|
|
14
|
+
const config = [{
|
|
15
|
+
tag: /^500$/u,
|
|
16
|
+
subfields: [{
|
|
17
|
+
code: /4/u
|
|
18
|
+
}]
|
|
19
|
+
}];
|
|
20
|
+
const validator = await (0, _subfieldExclusion.default)(config);
|
|
21
|
+
(0, _chai.expect)(validator).to.be.an('object').that.has.any.keys('description', 'validate');
|
|
22
|
+
(0, _chai.expect)(validator.description).to.be.a('string');
|
|
23
|
+
(0, _chai.expect)(validator.validate).to.be.a('function');
|
|
24
|
+
});
|
|
25
|
+
it('Creates a validator from complex config', async () => {
|
|
26
|
+
const config = [{
|
|
27
|
+
tag: /^210$/u,
|
|
28
|
+
ind2: /\s/u,
|
|
29
|
+
subfields: [{
|
|
30
|
+
code: /2/u,
|
|
31
|
+
value: /.+/u
|
|
32
|
+
}]
|
|
33
|
+
}];
|
|
34
|
+
const validator = await (0, _subfieldExclusion.default)(config);
|
|
35
|
+
(0, _chai.expect)(validator).to.be.an('object').that.has.any.keys('description', 'validate');
|
|
36
|
+
(0, _chai.expect)(validator.description).to.be.a('string');
|
|
37
|
+
(0, _chai.expect)(validator.validate).to.be.a('function');
|
|
38
|
+
});
|
|
39
|
+
it('Fails to create a validator from invalid config - subfields missing', () => {
|
|
40
|
+
const config = [{
|
|
41
|
+
tag: /^210$/u
|
|
42
|
+
}];
|
|
43
|
+
try {
|
|
44
|
+
(0, _subfieldExclusion.default)(config);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
(0, _chai.expect)(error).to.be.an('error').with.property('message', 'Configuration not valid - missing mandatory element: subfields');
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
it('Fails to create a validator from invalid config - tag', () => {
|
|
50
|
+
const config = [{
|
|
51
|
+
tag: '500',
|
|
52
|
+
subfields: [{
|
|
53
|
+
code: /9/u,
|
|
54
|
+
value: /^(?!FENNI<KEEP>).*$/u
|
|
55
|
+
}]
|
|
56
|
+
}];
|
|
57
|
+
try {
|
|
58
|
+
(0, _subfieldExclusion.default)(config);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
(0, _chai.expect)(error).to.be.an('error').with.property('message', 'Configuration not valid - invalid data type for: tag');
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
it('Fails to create a validator from invalid config - missing array', () => {
|
|
64
|
+
const config = {
|
|
65
|
+
tag: '500',
|
|
66
|
+
subfields: [{
|
|
67
|
+
code: /9/u,
|
|
68
|
+
value: /^(?!FENNI<KEEP>).*$/u
|
|
69
|
+
}]
|
|
70
|
+
};
|
|
71
|
+
try {
|
|
72
|
+
(0, _subfieldExclusion.default)(config);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
(0, _chai.expect)(error).to.be.an('error').with.property('message', 'Configuration array not provided');
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
it('Fails to create a validator from invalid config - code', () => {
|
|
78
|
+
const config = [{
|
|
79
|
+
tag: /^500$/u,
|
|
80
|
+
subfields: [{
|
|
81
|
+
code: 9,
|
|
82
|
+
value: /^(?!FENNI<KEEP>).*$/u
|
|
83
|
+
}]
|
|
84
|
+
}];
|
|
85
|
+
try {
|
|
86
|
+
(0, _subfieldExclusion.default)(config);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
(0, _chai.expect)(error).to.be.an('error').with.property('message', 'Configuration not valid - invalid data type for: code');
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
it('Fails to create a validator from invalid config - value', () => {
|
|
92
|
+
const config = [{
|
|
93
|
+
tag: /^500$/u,
|
|
94
|
+
subfields: [{
|
|
95
|
+
code: /9/u,
|
|
96
|
+
value: 'Fenni'
|
|
97
|
+
}]
|
|
98
|
+
}];
|
|
99
|
+
try {
|
|
100
|
+
(0, _subfieldExclusion.default)(config);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
(0, _chai.expect)(error).to.be.an('error').with.property('message', 'Configuration not valid - invalid data type for: value');
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
it('Fails to create a validator from invalid config - missing mandatory: tag', () => {
|
|
106
|
+
const config = [{
|
|
107
|
+
value: /^500$/u,
|
|
108
|
+
subfields: [{
|
|
109
|
+
code: /9/u,
|
|
110
|
+
value: /^(?!FENNI<KEEP>).*$/u
|
|
111
|
+
}]
|
|
112
|
+
}];
|
|
113
|
+
try {
|
|
114
|
+
(0, _subfieldExclusion.default)(config);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
(0, _chai.expect)(error).to.be.an('error').with.property('message', 'Configuration not valid - missing mandatory element: tag');
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
it('Fails to create a validator from invalid config - subfield not object: array', () => {
|
|
120
|
+
const config = [{
|
|
121
|
+
tag: /^500$/u,
|
|
122
|
+
subfields: [['/9/', '/^(?!FENNI<KEEP>).*$/'], {
|
|
123
|
+
value: /^(?!FENNI<KEEP>).*$/u
|
|
124
|
+
}]
|
|
125
|
+
}];
|
|
126
|
+
try {
|
|
127
|
+
(0, _subfieldExclusion.default)(config);
|
|
128
|
+
} catch (error) {
|
|
129
|
+
(0, _chai.expect)(error).to.be.an('error').with.property('message', 'Configuration not valid - subfield: /9/,/^(?!FENNI<KEEP>).*$/ not object');
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
it('Fails to create a validator from invalid config - subfield not object: string', () => {
|
|
133
|
+
const config = [{
|
|
134
|
+
tag: /^500$/u,
|
|
135
|
+
subfields: ['/9/', '/^(?!FENNI<KEEP>).*$/', {
|
|
136
|
+
value: /^(?!FENNI<KEEP>).*$/u
|
|
137
|
+
}]
|
|
138
|
+
}];
|
|
139
|
+
try {
|
|
140
|
+
(0, _subfieldExclusion.default)(config);
|
|
141
|
+
} catch (error) {
|
|
142
|
+
(0, _chai.expect)(error).to.be.an('error').with.property('message', 'Configuration not valid - subfield: /9/ not object');
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
it('Fails to create a validator from invalid config - missing mandatory: subfield.code', () => {
|
|
146
|
+
const config = [{
|
|
147
|
+
tag: /^500$/u,
|
|
148
|
+
subfields: [{
|
|
149
|
+
code: /9/u,
|
|
150
|
+
value: /^(?!FENNI<KEEP>).*$/u
|
|
151
|
+
}, {
|
|
152
|
+
value: /^(?!FENNI<KEEP>).*$/u
|
|
153
|
+
}]
|
|
154
|
+
}];
|
|
155
|
+
try {
|
|
156
|
+
(0, _subfieldExclusion.default)(config);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
(0, _chai.expect)(error).to.be.an('error').with.property('message', 'Configuration not valid - missing mandatory element: code');
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
it('Fails to create a validator from invalid config - unidentified field: unidentified', () => {
|
|
162
|
+
const config = [{
|
|
163
|
+
tag: /^500$/u,
|
|
164
|
+
unidentified: /^500$/u,
|
|
165
|
+
subfields: [{
|
|
166
|
+
code: /9/u,
|
|
167
|
+
value: /^(?!FENNI<KEEP>).*$/u
|
|
168
|
+
}, {
|
|
169
|
+
value: /^(?!FENNI<KEEP>).*$/u
|
|
170
|
+
}]
|
|
171
|
+
}];
|
|
172
|
+
try {
|
|
173
|
+
(0, _subfieldExclusion.default)(config);
|
|
174
|
+
} catch (error) {
|
|
175
|
+
(0, _chai.expect)(error).to.be.an('error').with.property('message', 'Configuration not valid - unidentified value: unidentified');
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Simple configuration https://github.com/NatLibFi/marc-record-validators-melinda/issues/46
|
|
181
|
+
describe('#validate: Simple configuration (spec)', () => {
|
|
182
|
+
const config = [{
|
|
183
|
+
tag: /^100$/u,
|
|
184
|
+
subfields: [{
|
|
185
|
+
code: /4/u
|
|
186
|
+
}]
|
|
187
|
+
}];
|
|
188
|
+
const recordValid = new _marcRecord.MarcRecord({
|
|
189
|
+
leader: 'foo',
|
|
190
|
+
fields: [{
|
|
191
|
+
tag: '100',
|
|
192
|
+
ind1: ' ',
|
|
193
|
+
ind2: ' ',
|
|
194
|
+
subfields: [{
|
|
195
|
+
code: 'a',
|
|
196
|
+
value: 'Foo Bar'
|
|
197
|
+
}]
|
|
198
|
+
}, {
|
|
199
|
+
tag: '245',
|
|
200
|
+
ind1: ' ',
|
|
201
|
+
ind2: ' ',
|
|
202
|
+
subfields: [{
|
|
203
|
+
code: 'a',
|
|
204
|
+
value: 'Fubar'
|
|
205
|
+
}]
|
|
206
|
+
}]
|
|
207
|
+
});
|
|
208
|
+
const recordInvalid = new _marcRecord.MarcRecord({
|
|
209
|
+
leader: 'foo',
|
|
210
|
+
fields: [{
|
|
211
|
+
tag: '100',
|
|
212
|
+
ind1: ' ',
|
|
213
|
+
ind2: ' ',
|
|
214
|
+
subfields: [{
|
|
215
|
+
code: 'a',
|
|
216
|
+
value: 'Foo Bar'
|
|
217
|
+
}, {
|
|
218
|
+
code: '4',
|
|
219
|
+
value: 'att'
|
|
220
|
+
}]
|
|
221
|
+
}, {
|
|
222
|
+
tag: '245',
|
|
223
|
+
ind1: ' ',
|
|
224
|
+
ind2: ' ',
|
|
225
|
+
subfields: [{
|
|
226
|
+
code: 'a',
|
|
227
|
+
value: 'Fubar'
|
|
228
|
+
}]
|
|
229
|
+
}]
|
|
230
|
+
});
|
|
231
|
+
const recordInvalidFixed = new _marcRecord.MarcRecord({
|
|
232
|
+
leader: 'foo',
|
|
233
|
+
fields: [{
|
|
234
|
+
tag: '100',
|
|
235
|
+
ind1: ' ',
|
|
236
|
+
ind2: ' ',
|
|
237
|
+
subfields: [{
|
|
238
|
+
code: 'a',
|
|
239
|
+
value: 'Foo Bar'
|
|
240
|
+
}]
|
|
241
|
+
}, {
|
|
242
|
+
tag: '245',
|
|
243
|
+
ind1: ' ',
|
|
244
|
+
ind2: ' ',
|
|
245
|
+
subfields: [{
|
|
246
|
+
code: 'a',
|
|
247
|
+
value: 'Fubar'
|
|
248
|
+
}]
|
|
249
|
+
}]
|
|
250
|
+
});
|
|
251
|
+
it('Finds the record valid (spec)', async () => {
|
|
252
|
+
const validator = await (0, _subfieldExclusion.default)(config);
|
|
253
|
+
const result = await validator.validate(recordValid);
|
|
254
|
+
(0, _chai.expect)(result).to.eql({
|
|
255
|
+
valid: true,
|
|
256
|
+
message: []
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
it('Finds the record invalid (spec)', async () => {
|
|
260
|
+
const validator = await (0, _subfieldExclusion.default)(config);
|
|
261
|
+
const result = await validator.validate(recordInvalid);
|
|
262
|
+
(0, _chai.expect)(result).to.eql({
|
|
263
|
+
valid: false,
|
|
264
|
+
message: ['Subfield $100$$4should be excluded']
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
it('Repairs invalid record', async () => {
|
|
268
|
+
const validator = await (0, _subfieldExclusion.default)(config);
|
|
269
|
+
await validator.fix(recordInvalid);
|
|
270
|
+
(0, _chai.expect)(recordInvalid.equalsTo(recordInvalidFixed)).to.eql(true);
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
describe('#validate: Remove only subfield -> remove field as well', () => {
|
|
274
|
+
const config = [{
|
|
275
|
+
tag: /^041$/u,
|
|
276
|
+
subfields: [{
|
|
277
|
+
code: /^[ad]$/u,
|
|
278
|
+
value: /^zxx$/u
|
|
279
|
+
}]
|
|
280
|
+
}];
|
|
281
|
+
const recordOriginal = new _marcRecord.MarcRecord({
|
|
282
|
+
leader: 'foo',
|
|
283
|
+
fields: [{
|
|
284
|
+
tag: '041',
|
|
285
|
+
ind1: ' ',
|
|
286
|
+
ind2: ' ',
|
|
287
|
+
subfields: [{
|
|
288
|
+
code: 'a',
|
|
289
|
+
value: 'zxx'
|
|
290
|
+
}]
|
|
291
|
+
}, {
|
|
292
|
+
tag: '245',
|
|
293
|
+
ind1: ' ',
|
|
294
|
+
ind2: ' ',
|
|
295
|
+
subfields: [{
|
|
296
|
+
code: 'a',
|
|
297
|
+
value: 'Fubar'
|
|
298
|
+
}]
|
|
299
|
+
}]
|
|
300
|
+
});
|
|
301
|
+
const recordModified = new _marcRecord.MarcRecord({
|
|
302
|
+
leader: 'foo',
|
|
303
|
+
fields: [{
|
|
304
|
+
tag: '245',
|
|
305
|
+
ind1: ' ',
|
|
306
|
+
ind2: ' ',
|
|
307
|
+
subfields: [{
|
|
308
|
+
code: 'a',
|
|
309
|
+
value: 'Fubar'
|
|
310
|
+
}]
|
|
311
|
+
}]
|
|
312
|
+
});
|
|
313
|
+
it('Finds the record with 041$a zxx invalid (spec)', async () => {
|
|
314
|
+
const validator = await (0, _subfieldExclusion.default)(config);
|
|
315
|
+
const result = await validator.validate(recordOriginal);
|
|
316
|
+
(0, _chai.expect)(result).to.eql({
|
|
317
|
+
valid: false,
|
|
318
|
+
message: ['Subfield $041$$ashould be excluded']
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
it('Repairs invalid record', async () => {
|
|
322
|
+
const validator = await (0, _subfieldExclusion.default)(config);
|
|
323
|
+
await validator.fix(recordOriginal);
|
|
324
|
+
(0, _chai.expect)(recordOriginal.equalsTo(recordModified)).to.eql(true);
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
// Complex configuration https://github.com/NatLibFi/marc-record-validators-melinda/issues/46
|
|
329
|
+
describe('#validate: Complex configuration (spec)', () => {
|
|
330
|
+
const config = [{
|
|
331
|
+
tag: /^210$/u,
|
|
332
|
+
ind2: /\s/u,
|
|
333
|
+
subfields: [{
|
|
334
|
+
code: /2/u,
|
|
335
|
+
value: /.+/u
|
|
336
|
+
}]
|
|
337
|
+
}];
|
|
338
|
+
const recordValid = new _marcRecord.MarcRecord({
|
|
339
|
+
leader: 'foo',
|
|
340
|
+
fields: [{
|
|
341
|
+
tag: '210',
|
|
342
|
+
ind1: ' ',
|
|
343
|
+
ind2: ' ',
|
|
344
|
+
subfields: [{
|
|
345
|
+
code: 'a',
|
|
346
|
+
value: 'Foo'
|
|
347
|
+
}]
|
|
348
|
+
}, {
|
|
349
|
+
tag: '245',
|
|
350
|
+
ind1: ' ',
|
|
351
|
+
ind2: ' ',
|
|
352
|
+
subfields: [{
|
|
353
|
+
code: 'a',
|
|
354
|
+
value: 'Fubar'
|
|
355
|
+
}]
|
|
356
|
+
}]
|
|
357
|
+
});
|
|
358
|
+
const recordInvalid = new _marcRecord.MarcRecord({
|
|
359
|
+
leader: 'foo',
|
|
360
|
+
fields: [{
|
|
361
|
+
tag: '210',
|
|
362
|
+
ind1: ' ',
|
|
363
|
+
ind2: ' ',
|
|
364
|
+
subfields: [{
|
|
365
|
+
code: 'a',
|
|
366
|
+
value: 'Foo'
|
|
367
|
+
}, {
|
|
368
|
+
code: '2',
|
|
369
|
+
value: 'dnlm'
|
|
370
|
+
}]
|
|
371
|
+
}, {
|
|
372
|
+
tag: '245',
|
|
373
|
+
ind1: ' ',
|
|
374
|
+
ind2: ' ',
|
|
375
|
+
subfields: [{
|
|
376
|
+
code: 'a',
|
|
377
|
+
value: 'Fubar'
|
|
378
|
+
}]
|
|
379
|
+
}]
|
|
380
|
+
});
|
|
381
|
+
const recordInvalidFixed = new _marcRecord.MarcRecord({
|
|
382
|
+
leader: 'foo',
|
|
383
|
+
fields: [{
|
|
384
|
+
tag: '210',
|
|
385
|
+
ind1: ' ',
|
|
386
|
+
ind2: ' ',
|
|
387
|
+
subfields: [{
|
|
388
|
+
code: 'a',
|
|
389
|
+
value: 'Foo'
|
|
390
|
+
}]
|
|
391
|
+
}, {
|
|
392
|
+
tag: '245',
|
|
393
|
+
ind1: ' ',
|
|
394
|
+
ind2: ' ',
|
|
395
|
+
subfields: [{
|
|
396
|
+
code: 'a',
|
|
397
|
+
value: 'Fubar'
|
|
398
|
+
}]
|
|
399
|
+
}]
|
|
400
|
+
});
|
|
401
|
+
it('Finds the record valid (spec)', async () => {
|
|
402
|
+
const validator = await (0, _subfieldExclusion.default)(config);
|
|
403
|
+
const result = await validator.validate(recordValid);
|
|
404
|
+
(0, _chai.expect)(result).to.eql({
|
|
405
|
+
valid: true,
|
|
406
|
+
message: []
|
|
407
|
+
});
|
|
408
|
+
});
|
|
409
|
+
it('Finds the record invalid (spec)', async () => {
|
|
410
|
+
const validator = await (0, _subfieldExclusion.default)(config);
|
|
411
|
+
const result = await validator.validate(recordInvalid);
|
|
412
|
+
(0, _chai.expect)(result).to.eql({
|
|
413
|
+
valid: false,
|
|
414
|
+
message: ['Subfield $210$$2should be excluded']
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
it('Repairs invalid record', async () => {
|
|
418
|
+
const validator = await (0, _subfieldExclusion.default)(config);
|
|
419
|
+
await validator.fix(recordInvalid);
|
|
420
|
+
(0, _chai.expect)(recordInvalid.equalsTo(recordInvalidFixed)).to.eql(true);
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
// More special cases to increase coverage
|
|
425
|
+
describe('#validate: Custom configuration', () => {
|
|
426
|
+
const configInd = [{
|
|
427
|
+
tag: /^500$/u,
|
|
428
|
+
ind1: /^8$/u,
|
|
429
|
+
ind2: /^4$/u,
|
|
430
|
+
subfields: [{
|
|
431
|
+
code: /2/u,
|
|
432
|
+
value: /.+/u
|
|
433
|
+
}]
|
|
434
|
+
}];
|
|
435
|
+
const recordValid = new _marcRecord.MarcRecord({
|
|
436
|
+
leader: 'foo',
|
|
437
|
+
fields: [{
|
|
438
|
+
tag: '210',
|
|
439
|
+
ind1: ' ',
|
|
440
|
+
ind2: ' ',
|
|
441
|
+
subfields: [{
|
|
442
|
+
code: 'a',
|
|
443
|
+
value: 'Foo'
|
|
444
|
+
}]
|
|
445
|
+
}, {
|
|
446
|
+
tag: '500',
|
|
447
|
+
subfields: [{
|
|
448
|
+
code: 'a',
|
|
449
|
+
value: 'Foo'
|
|
450
|
+
}, {
|
|
451
|
+
code: '2',
|
|
452
|
+
value: 'dnlm'
|
|
453
|
+
}]
|
|
454
|
+
}]
|
|
455
|
+
});
|
|
456
|
+
const recordIndInvalid = new _marcRecord.MarcRecord({
|
|
457
|
+
leader: 'foo',
|
|
458
|
+
fields: [{
|
|
459
|
+
tag: '245',
|
|
460
|
+
ind1: ' ',
|
|
461
|
+
ind2: ' ',
|
|
462
|
+
subfields: [{
|
|
463
|
+
code: 'a',
|
|
464
|
+
value: 'Fubar'
|
|
465
|
+
}]
|
|
466
|
+
}, {
|
|
467
|
+
tag: '500',
|
|
468
|
+
ind1: '8',
|
|
469
|
+
ind2: '4',
|
|
470
|
+
subfields: [{
|
|
471
|
+
code: 'a',
|
|
472
|
+
value: 'Foo'
|
|
473
|
+
}, {
|
|
474
|
+
code: '2',
|
|
475
|
+
value: 'dnlm'
|
|
476
|
+
}]
|
|
477
|
+
}]
|
|
478
|
+
});
|
|
479
|
+
const recordIndInvalidFixed = new _marcRecord.MarcRecord({
|
|
480
|
+
leader: 'foo',
|
|
481
|
+
fields: [{
|
|
482
|
+
tag: '245',
|
|
483
|
+
ind1: ' ',
|
|
484
|
+
ind2: ' ',
|
|
485
|
+
subfields: [{
|
|
486
|
+
code: 'a',
|
|
487
|
+
value: 'Fubar'
|
|
488
|
+
}]
|
|
489
|
+
}, {
|
|
490
|
+
tag: '500',
|
|
491
|
+
ind1: '8',
|
|
492
|
+
ind2: '4',
|
|
493
|
+
subfields: [{
|
|
494
|
+
code: 'a',
|
|
495
|
+
value: 'Foo'
|
|
496
|
+
}]
|
|
497
|
+
}]
|
|
498
|
+
});
|
|
499
|
+
it('Finds the record valid - Ind1&Ind2', async () => {
|
|
500
|
+
const validator = await (0, _subfieldExclusion.default)(configInd);
|
|
501
|
+
const result = await validator.validate(recordValid);
|
|
502
|
+
(0, _chai.expect)(result).to.eql({
|
|
503
|
+
valid: true,
|
|
504
|
+
message: []
|
|
505
|
+
});
|
|
506
|
+
});
|
|
507
|
+
it('Finds the record invalid - Ind', async () => {
|
|
508
|
+
const validator = await (0, _subfieldExclusion.default)(configInd);
|
|
509
|
+
const result = await validator.validate(recordIndInvalid);
|
|
510
|
+
(0, _chai.expect)(result).to.eql({
|
|
511
|
+
valid: false,
|
|
512
|
+
message: ['Subfield $500$$2should be excluded']
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
it('Repairs invalid record', async () => {
|
|
516
|
+
const validator = await (0, _subfieldExclusion.default)(configInd);
|
|
517
|
+
await validator.fix(recordIndInvalid);
|
|
518
|
+
(0, _chai.expect)(recordIndInvalid.equalsTo(recordIndInvalidFixed)).to.eql(true);
|
|
519
|
+
});
|
|
520
|
+
});
|
|
521
|
+
});
|
|
32
522
|
//# sourceMappingURL=subfield-exclusion.spec.js.map
|