@natlibfi/marc-record-validators-melinda 12.0.0-alpha.9 → 12.0.1-alpha.1
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/dist/access-rights.test.js +1 -1
- package/dist/access-rights.test.js.map +1 -1
- package/dist/addMissingField337.test.js +1 -1
- package/dist/addMissingField337.test.js.map +1 -1
- package/dist/addMissingField338.test.js +1 -1
- package/dist/addMissingField338.test.js.map +1 -1
- package/dist/cyrillux-usemarcon-replacement.test.js +4 -7
- package/dist/cyrillux-usemarcon-replacement.test.js.map +2 -2
- package/dist/cyrillux.test.js +1 -1
- package/dist/cyrillux.test.js.map +1 -1
- package/dist/disambiguateSeriesStatements.test.js +1 -7
- package/dist/disambiguateSeriesStatements.test.js.map +2 -2
- package/dist/double-commas.test.js +1 -1
- package/dist/double-commas.test.js.map +1 -1
- package/dist/drop-terms.js +122 -0
- package/dist/drop-terms.js.map +7 -0
- package/dist/drop-terms.test.js +56 -0
- package/dist/drop-terms.test.js.map +7 -0
- package/dist/empty-fields.test.js +1 -1
- package/dist/empty-fields.test.js.map +1 -1
- package/dist/ending-punctuation.test.js +39 -19
- package/dist/ending-punctuation.test.js.map +2 -2
- package/dist/field-008-18-34-character-groups.test.js +2 -8
- package/dist/field-008-18-34-character-groups.test.js.map +2 -2
- package/dist/field-505-separators.test.js +1 -7
- package/dist/field-505-separators.test.js.map +2 -2
- package/dist/field-521-fix.test.js +1 -7
- package/dist/field-521-fix.test.js.map +2 -2
- package/dist/field-exclusion.test.js +11 -8
- package/dist/field-exclusion.test.js.map +2 -2
- package/dist/field-structure.test.js +1 -1
- package/dist/field-structure.test.js.map +1 -1
- package/dist/fields-present.test.js +1 -1
- package/dist/fields-present.test.js.map +1 -1
- package/dist/fix-33X.test.js +1 -1
- package/dist/fix-33X.test.js.map +1 -1
- package/dist/fix-country-codes.test.js +1 -7
- package/dist/fix-country-codes.test.js.map +2 -2
- package/dist/fix-sami-041.js +87 -0
- package/dist/fix-sami-041.js.map +7 -0
- package/dist/fix-sami-041.test.js +40 -0
- package/dist/fix-sami-041.test.js.map +7 -0
- package/dist/fixRelatorTerms.test.js +2 -8
- package/dist/fixRelatorTerms.test.js.map +2 -2
- package/dist/fixed-fields.test.js +29 -18
- package/dist/fixed-fields.test.js.map +2 -2
- package/dist/identical-fields.test.js +1 -1
- package/dist/identical-fields.test.js.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +2 -2
- package/dist/indicator-fixes.js +10 -0
- package/dist/indicator-fixes.js.map +2 -2
- package/dist/indicator-fixes.test.js +1 -7
- package/dist/indicator-fixes.test.js.map +2 -2
- package/dist/isbn-issn.js +1 -1
- package/dist/isbn-issn.js.map +2 -2
- package/dist/isbn-issn.test.js +9 -6
- package/dist/isbn-issn.test.js.map +2 -2
- package/dist/item-language.test.js +1 -1
- package/dist/item-language.test.js.map +2 -2
- package/dist/merge-fields.test.js +2 -7
- package/dist/merge-fields.test.js.map +2 -2
- package/dist/mergeField500Lisapainokset.test.js +1 -7
- package/dist/mergeField500Lisapainokset.test.js.map +2 -2
- package/dist/mergeRelatorTermFields.test.js +1 -7
- package/dist/mergeRelatorTermFields.test.js.map +2 -2
- package/dist/multiple-subfield-0.test.js +1 -7
- package/dist/multiple-subfield-0.test.js.map +2 -2
- package/dist/normalize-dashes.test.js +1 -7
- package/dist/normalize-dashes.test.js.map +2 -2
- package/dist/normalize-identifiers.test.js +1 -7
- package/dist/normalize-identifiers.test.js.map +2 -2
- package/dist/normalize-qualifying-information.test.js +1 -7
- package/dist/normalize-qualifying-information.test.js.map +2 -2
- package/dist/normalize-utf8-diacritics.test.js +1 -7
- package/dist/normalize-utf8-diacritics.test.js.map +2 -2
- package/dist/normalizeFieldForComparison.js +24 -0
- package/dist/normalizeFieldForComparison.js.map +2 -2
- package/dist/punctuation.test.js +1 -7
- package/dist/punctuation.test.js.map +2 -2
- package/dist/punctuation2.test.js +2 -8
- package/dist/punctuation2.test.js.map +2 -2
- package/dist/reindexSubfield6OccurenceNumbers.test.js +1 -7
- package/dist/reindexSubfield6OccurenceNumbers.test.js.map +2 -2
- package/dist/remove-041-zxx.js +56 -0
- package/dist/remove-041-zxx.js.map +7 -0
- package/dist/remove-041-zxx.test.js +40 -0
- package/dist/remove-041-zxx.test.js.map +7 -0
- package/dist/removeDuplicateDataFields.test.js +2 -8
- package/dist/removeDuplicateDataFields.test.js.map +2 -2
- package/dist/removeInferiorDataFields.js +1 -9
- package/dist/removeInferiorDataFields.js.map +2 -2
- package/dist/removeInferiorDataFields.test.js +1 -7
- package/dist/removeInferiorDataFields.test.js.map +2 -2
- package/dist/resolvable-ext-references-melinda.test.js +1 -1
- package/dist/resolvable-ext-references-melinda.test.js.map +2 -2
- package/dist/resolveOrphanedSubfield6s.js +1 -3
- package/dist/resolveOrphanedSubfield6s.js.map +2 -2
- package/dist/resolveOrphanedSubfield6s.test.js +1 -7
- package/dist/resolveOrphanedSubfield6s.test.js.map +2 -2
- package/dist/sanitize-vocabulary-source-codes.test.js +1 -7
- package/dist/sanitize-vocabulary-source-codes.test.js.map +2 -2
- package/dist/sort-tags.test.js +1 -1
- package/dist/sort-tags.test.js.map +1 -1
- package/dist/sortFields.js +16 -1
- package/dist/sortFields.js.map +2 -2
- package/dist/sortFields.test.js +1 -7
- package/dist/sortFields.test.js.map +2 -2
- package/dist/sortRelatorTerms.test.js +1 -7
- package/dist/sortRelatorTerms.test.js.map +2 -2
- package/dist/sortSubfields.js +3 -1
- package/dist/sortSubfields.js.map +2 -2
- package/dist/sortSubfields.test.js +1 -7
- package/dist/sortSubfields.test.js.map +2 -2
- package/dist/stripPunctuation.js +7 -4
- package/dist/stripPunctuation.js.map +2 -2
- package/dist/stripPunctuation.test.js +1 -7
- package/dist/stripPunctuation.test.js.map +2 -2
- package/dist/subfield-exclusion.test.js +1 -1
- package/dist/subfield-exclusion.test.js.map +1 -1
- package/dist/subfield6Utils.js +1 -13
- package/dist/subfield6Utils.js.map +2 -2
- package/dist/subfieldValueNormalizations.test.js +1 -7
- package/dist/subfieldValueNormalizations.test.js.map +2 -2
- package/dist/sync-007-and-300.test.js +1 -7
- package/dist/sync-007-and-300.test.js.map +2 -2
- package/dist/sync-language.js +103 -0
- package/dist/sync-language.js.map +7 -0
- package/dist/sync-language.test.js +40 -0
- package/dist/sync-language.test.js.map +7 -0
- package/dist/translate-terms.js +121 -85
- package/dist/translate-terms.js.map +3 -3
- package/dist/translate-terms.test.js +5 -8
- package/dist/translate-terms.test.js.map +2 -2
- package/dist/unicode-decomposition.test.js +1 -1
- package/dist/unicode-decomposition.test.js.map +1 -1
- package/dist/update-field-540.test.js +2 -8
- package/dist/update-field-540.test.js.map +2 -2
- package/dist/urn.test.js +2 -8
- package/dist/urn.test.js.map +2 -2
- package/package.json +18 -16
- package/src/access-rights.test.js +1 -1
- package/src/addMissingField337.test.js +1 -1
- package/src/addMissingField338.test.js +1 -1
- package/src/cyrillux-usemarcon-replacement.test.js +4 -9
- package/src/cyrillux.test.js +1 -1
- package/src/disambiguateSeriesStatements.test.js +3 -8
- package/src/double-commas.test.js +1 -1
- package/src/drop-terms.js +162 -0
- package/src/drop-terms.test.js +81 -0
- package/src/empty-fields.test.js +1 -1
- package/src/ending-punctuation.test.js +28 -20
- package/src/field-008-18-34-character-groups.test.js +4 -9
- package/src/field-505-separators.test.js +3 -8
- package/src/field-521-fix.test.js +3 -8
- package/src/field-exclusion.test.js +10 -8
- package/src/field-structure.test.js +1 -1
- package/src/fields-present.test.js +1 -1
- package/src/fix-33X.test.js +1 -1
- package/src/fix-country-codes.test.js +3 -8
- package/src/fix-sami-041.js +113 -0
- package/src/fix-sami-041.test.js +52 -0
- package/src/fixRelatorTerms.test.js +4 -9
- package/src/fixed-fields.test.js +24 -18
- package/src/identical-fields.test.js +1 -1
- package/src/index.js +8 -1
- package/src/indicator-fixes.js +12 -0
- package/src/indicator-fixes.test.js +3 -8
- package/src/isbn-issn.js +1 -1
- package/src/isbn-issn.test.js +8 -6
- package/src/item-language.test.js +2 -2
- package/src/merge-fields.test.js +3 -8
- package/src/mergeField500Lisapainokset.test.js +3 -8
- package/src/mergeRelatorTermFields.test.js +3 -8
- package/src/multiple-subfield-0.test.js +3 -8
- package/src/normalize-dashes.test.js +3 -8
- package/src/normalize-identifiers.test.js +3 -8
- package/src/normalize-qualifying-information.test.js +3 -8
- package/src/normalize-utf8-diacritics.test.js +3 -8
- package/src/normalizeFieldForComparison.js +26 -0
- package/src/punctuation.test.js +3 -8
- package/src/punctuation2.test.js +4 -9
- package/src/reindexSubfield6OccurenceNumbers.test.js +3 -8
- package/src/remove-041-zxx.js +85 -0
- package/src/remove-041-zxx.test.js +52 -0
- package/src/removeDuplicateDataFields.test.js +4 -9
- package/src/removeInferiorDataFields.js +7 -7
- package/src/removeInferiorDataFields.test.js +3 -8
- package/src/resolvable-ext-references-melinda.test.js +5 -5
- package/src/resolveOrphanedSubfield6s.js +3 -3
- package/src/resolveOrphanedSubfield6s.test.js +3 -8
- package/src/sanitize-vocabulary-source-codes.test.js +3 -8
- package/src/sort-tags.test.js +1 -1
- package/src/sortFields.js +20 -1
- package/src/sortFields.test.js +3 -8
- package/src/sortRelatorTerms.test.js +3 -8
- package/src/sortSubfields.js +3 -1
- package/src/sortSubfields.test.js +3 -8
- package/src/stripPunctuation.js +9 -6
- package/src/stripPunctuation.test.js +3 -8
- package/src/subfield-exclusion.test.js +1 -1
- package/src/subfield6Utils.js +13 -13
- package/src/subfieldValueNormalizations.test.js +3 -8
- package/src/sync-007-and-300.test.js +3 -8
- package/src/sync-language.js +148 -0
- package/src/sync-language.test.js +52 -0
- package/src/translate-terms.js +158 -103
- package/src/translate-terms.test.js +12 -16
- package/src/unicode-decomposition.test.js +1 -1
- package/src/update-field-540.test.js +4 -9
- package/src/urn.test.js +4 -9
- package/test-fixtures/drop-terms/01/expectedResult.json +31 -0
- package/test-fixtures/drop-terms/01/metadata.json +6 -0
- package/test-fixtures/drop-terms/01/record.json +35 -0
- package/test-fixtures/drop-terms/02/expectedResult.json +7 -0
- package/test-fixtures/drop-terms/02/metadata.json +6 -0
- package/test-fixtures/drop-terms/02/record.json +40 -0
- package/test-fixtures/drop-terms/03/expectedResult.json +6 -0
- package/test-fixtures/drop-terms/03/metadata.json +18 -0
- package/test-fixtures/drop-terms/03/record.json +39 -0
- package/test-fixtures/drop-terms/04/expectedResult.json +6 -0
- package/test-fixtures/drop-terms/04/metadata.json +19 -0
- package/test-fixtures/drop-terms/04/record.json +24 -0
- package/test-fixtures/fix-language-codes/02/metadata.json +1 -1
- package/test-fixtures/fix-sami-041/01/expectedResult.json +6 -0
- package/test-fixtures/fix-sami-041/01/metadata.json +4 -0
- package/test-fixtures/fix-sami-041/01/record.json +13 -0
- package/test-fixtures/fix-sami-041/02/expectedResult.json +10 -0
- package/test-fixtures/fix-sami-041/02/metadata.json +4 -0
- package/test-fixtures/fix-sami-041/02/record.json +8 -0
- package/test-fixtures/fix-sami-041/03/expectedResult.json +5 -0
- package/test-fixtures/fix-sami-041/03/metadata.json +5 -0
- package/test-fixtures/fix-sami-041/03/record.json +8 -0
- package/test-fixtures/fix-sami-041/04/expectedResult.json +7 -0
- package/test-fixtures/fix-sami-041/04/metadata.json +4 -0
- package/test-fixtures/fix-sami-041/04/record.json +10 -0
- package/test-fixtures/fix-sami-041/05/expectedResult.json +10 -0
- package/test-fixtures/fix-sami-041/05/metadata.json +6 -0
- package/test-fixtures/fix-sami-041/05/record.json +8 -0
- package/test-fixtures/indicator-fixes/11/expectedResult.json +10 -0
- package/test-fixtures/indicator-fixes/11/metadata.json +4 -0
- package/test-fixtures/indicator-fixes/11/record.json +10 -0
- package/test-fixtures/merge-fields/f05/metadata.json +1 -1
- package/test-fixtures/remove-041-zxx/01/expectedResult.json +5 -0
- package/test-fixtures/remove-041-zxx/01/metadata.json +5 -0
- package/test-fixtures/remove-041-zxx/01/record.json +10 -0
- package/test-fixtures/remove-041-zxx/02/expectedResult.json +7 -0
- package/test-fixtures/remove-041-zxx/02/metadata.json +5 -0
- package/test-fixtures/remove-041-zxx/02/record.json +9 -0
- package/test-fixtures/remove-041-zxx/11/expectedResult.json +10 -0
- package/test-fixtures/remove-041-zxx/11/metadata.json +5 -0
- package/test-fixtures/remove-041-zxx/11/record.json +9 -0
- package/test-fixtures/remove-041-zxx/12/expectedResult.json +10 -0
- package/test-fixtures/remove-041-zxx/12/metadata.json +5 -0
- package/test-fixtures/remove-041-zxx/12/record.json +9 -0
- package/test-fixtures/sort-fields/15/input.json +9 -0
- package/test-fixtures/sort-fields/15/metadata.json +5 -0
- package/test-fixtures/sort-fields/15/result.json +10 -0
- package/test-fixtures/sync-language/01/expectedResult.json +5 -0
- package/test-fixtures/sync-language/01/metadata.json +5 -0
- package/test-fixtures/sync-language/01/record.json +7 -0
- package/test-fixtures/sync-language/02/expectedResult.json +6 -0
- package/test-fixtures/sync-language/02/metadata.json +5 -0
- package/test-fixtures/sync-language/02/record.json +10 -0
- package/test-fixtures/sync-language/03/expectedResult.json +6 -0
- package/test-fixtures/sync-language/03/metadata.json +5 -0
- package/test-fixtures/sync-language/03/record.json +6 -0
- package/test-fixtures/sync-language/10/expectedResult.json +10 -0
- package/test-fixtures/sync-language/10/metadata.json +5 -0
- package/test-fixtures/sync-language/10/record.json +8 -0
- package/test-fixtures/sync-language/11/expectedResult.json +10 -0
- package/test-fixtures/sync-language/11/metadata.json +5 -0
- package/test-fixtures/sync-language/11/record.json +7 -0
- package/test-fixtures/sync-language/12/expectedResult.json +9 -0
- package/test-fixtures/sync-language/12/metadata.json +6 -0
- package/test-fixtures/sync-language/12/record.json +6 -0
- package/test-fixtures/sync-language/13/expectedResult.json +10 -0
- package/test-fixtures/sync-language/13/metadata.json +5 -0
- package/test-fixtures/sync-language/13/record.json +8 -0
- package/test-fixtures/sync-language/14/expectedResult.json +9 -0
- package/test-fixtures/sync-language/14/metadata.json +5 -0
- package/test-fixtures/sync-language/14/record.json +7 -0
- package/test-fixtures/sync-language/15/expectedResult.json +9 -0
- package/test-fixtures/sync-language/15/metadata.json +5 -0
- package/test-fixtures/sync-language/15/record.json +7 -0
- package/test-fixtures/translate-terms/05/expectedResult.json +12 -0
- package/test-fixtures/translate-terms/05/metadata.json +7 -0
- package/test-fixtures/translate-terms/05/record.json +11 -0
- package/test-fixtures/translate-terms/06/expectedResult.json +12 -0
- package/test-fixtures/translate-terms/06/metadata.json +7 -0
- package/test-fixtures/translate-terms/06/record.json +11 -0
- package/test-fixtures/translate-terms-data.js +23 -0
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"url": "https://github.com/NatLibFi/marc-record-validators-melinda"
|
|
15
15
|
},
|
|
16
16
|
"license": "MIT",
|
|
17
|
-
"version": "12.0.
|
|
17
|
+
"version": "12.0.1-alpha.1",
|
|
18
18
|
"main": "./dist/index.js",
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"access": "public"
|
|
@@ -29,40 +29,42 @@
|
|
|
29
29
|
"lint:dev": "eslint --fix ./src",
|
|
30
30
|
"test": "npm run lint && npm run test:base",
|
|
31
31
|
"test:base": "node --test --test-force-exit --experimental-test-coverage --test-reporter=spec './src/*.test.js' './src/**/*.test.js'",
|
|
32
|
+
"test:only": "npm run lint && npm run test:base:only",
|
|
33
|
+
"test:base:only": "node --test --test-only --test-force-exit --experimental-test-coverage --test-reporter=spec './src/*.test.js' './src/**/*.test.js'",
|
|
32
34
|
"dev:test": "cross-env DEBUG=@natlibfi/* NODE_ENV=test node --watch --test --experimental-test-coverage --test-reporter=spec './src/*.test.js' './src/**/*.test.js'",
|
|
33
35
|
"dev:debug": "cross-env LOG_LEVEL=debug DEBUG=@natlibfi/* NODE_ENV=test"
|
|
34
36
|
},
|
|
35
37
|
"dependencies": {
|
|
36
|
-
"@natlibfi/iso9-1995": "
|
|
37
|
-
"@natlibfi/issn-verify": "^
|
|
38
|
-
"@natlibfi/marc-record": "
|
|
39
|
-
"@natlibfi/marc-record-serializers": "
|
|
40
|
-
"@natlibfi/marc-record-validate": "
|
|
41
|
-
"@natlibfi/melinda-commons": "
|
|
42
|
-
"@natlibfi/sfs-4900": "
|
|
43
|
-
"@natlibfi/sru-client": "
|
|
38
|
+
"@natlibfi/iso9-1995": "^1.0.0",
|
|
39
|
+
"@natlibfi/issn-verify": "^2.0.0",
|
|
40
|
+
"@natlibfi/marc-record": "^10.0.1",
|
|
41
|
+
"@natlibfi/marc-record-serializers": "^11.0.1",
|
|
42
|
+
"@natlibfi/marc-record-validate": "^9.0.0",
|
|
43
|
+
"@natlibfi/melinda-commons": "^14.0.1",
|
|
44
|
+
"@natlibfi/sfs-4900": "^2.0.0",
|
|
45
|
+
"@natlibfi/sru-client": "^7.0.0",
|
|
44
46
|
"cld3-asm": "^4.0.0",
|
|
45
47
|
"clone": "^2.1.2",
|
|
46
48
|
"debug": "^4.4.3",
|
|
47
|
-
"isbn3": "^2.0.
|
|
49
|
+
"isbn3": "^2.0.1",
|
|
48
50
|
"langs": "^2.0.0",
|
|
49
51
|
"undici": "^7.16.0",
|
|
50
52
|
"xml2js": "^0.6.2",
|
|
51
53
|
"xregexp": "^5.1.2"
|
|
52
54
|
},
|
|
53
55
|
"peerDependencies": {
|
|
54
|
-
"@natlibfi/marc-record-validate": "
|
|
56
|
+
"@natlibfi/marc-record-validate": "^9.0.0"
|
|
55
57
|
},
|
|
56
58
|
"devDependencies": {
|
|
57
|
-
"@natlibfi/fixugen": "
|
|
58
|
-
"@natlibfi/fixura": "
|
|
59
|
-
"cross-env": "^10.
|
|
60
|
-
"esbuild": "^0.
|
|
59
|
+
"@natlibfi/fixugen": "^3.0.0",
|
|
60
|
+
"@natlibfi/fixura": "^4.0.0",
|
|
61
|
+
"cross-env": "^10.1.0",
|
|
62
|
+
"esbuild": "^0.27.1",
|
|
61
63
|
"eslint": "^9.39.1",
|
|
62
64
|
"fetch-mock": "^12.6.0"
|
|
63
65
|
},
|
|
64
66
|
"overrides": {
|
|
65
67
|
"nanoid": "^3.3.8"
|
|
66
68
|
},
|
|
67
|
-
"nvolkComment": "cld3-asm 4.0.0 uses emscripten-wasm-loader ^3.0.3 which uses problematic, non-secure nanoid version 2.X.X.
|
|
69
|
+
"nvolkComment": "cld3-asm 4.0.0 uses emscripten-wasm-loader ^3.0.3 which uses problematic, non-secure nanoid version 2.X.X."
|
|
68
70
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
import {describe, it} from 'node:test';
|
|
3
3
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
4
|
-
import validatorFactory from '
|
|
4
|
+
import validatorFactory from './access-rights.js';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
describe('access-rights', async () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
3
|
-
import validatorFactory from '
|
|
3
|
+
import validatorFactory from './addMissingField337.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
3
|
-
import validatorFactory from '
|
|
3
|
+
import validatorFactory from './addMissingField338.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
6
|
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
|
-
import {after, before} from 'node:test';
|
|
3
2
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
4
3
|
import validatorFactory from './cyrillux-usemarcon-replacement.js';
|
|
5
4
|
import {READERS} from '@natlibfi/fixura';
|
|
6
5
|
import generateTests from '@natlibfi/fixugen';
|
|
7
6
|
|
|
8
|
-
before(() => {
|
|
9
|
-
MarcRecord.setValidationOptions({subfields: false, subfieldValues: false});
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
after(() => {
|
|
13
|
-
MarcRecord.setValidationOptions({});
|
|
14
|
-
});
|
|
15
|
-
|
|
16
7
|
generateTests({
|
|
17
8
|
callback,
|
|
18
9
|
path: [import.meta.dirname, '..', 'test-fixtures', 'cyrillux-usemarcon-replacement'],
|
|
@@ -23,7 +14,11 @@ generateTests({
|
|
|
23
14
|
},
|
|
24
15
|
hooks: {
|
|
25
16
|
before: async () => {
|
|
17
|
+
MarcRecord.setValidationOptions({subfields: false, subfieldValues: false});
|
|
26
18
|
testValidatorFactory();
|
|
19
|
+
},
|
|
20
|
+
after: async () => {
|
|
21
|
+
MarcRecord.setValidationOptions({});
|
|
27
22
|
}
|
|
28
23
|
}
|
|
29
24
|
});
|
package/src/cyrillux.test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
3
|
-
import validatorFactory from '
|
|
3
|
+
import validatorFactory from './cyrillux.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
6
|
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './disambiguateSeriesStatements.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -19,7 +19,7 @@ generateTests({
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/disambiguateSeriesStatements:test');
|
|
22
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/disambiguateSeriesStatements:test');
|
|
23
23
|
|
|
24
24
|
async function testValidatorFactory() {
|
|
25
25
|
const validator = await validatorFactory();
|
|
@@ -29,12 +29,7 @@ async function testValidatorFactory() {
|
|
|
29
29
|
assert.equal(typeof validator.validate, 'function');
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
async function callback({getFixture,
|
|
33
|
-
if (enabled === false) {
|
|
34
|
-
debug('TEST SKIPPED!');
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
32
|
+
async function callback({getFixture, fix = false}) {
|
|
38
33
|
const validator = await validatorFactory();
|
|
39
34
|
const record = new MarcRecord(getFixture('record.json'));
|
|
40
35
|
const expectedResult = getFixture('expectedResult.json');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
3
|
-
import validatorFactory from '
|
|
3
|
+
import validatorFactory from './double-commas.js';
|
|
4
4
|
import {describe, it} from 'node:test';
|
|
5
5
|
|
|
6
6
|
describe('double-commas', () => {
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// Author(s): Nicholas Volk
|
|
2
|
+
|
|
3
|
+
import clone from 'clone';
|
|
4
|
+
import createDebugLogger from 'debug';
|
|
5
|
+
import {fieldToString, nvdebug} from './utils.js';
|
|
6
|
+
import {getLexiconAndLanguage, getTermData, isLabel, isValidSubfield0} from './translate-terms.js';
|
|
7
|
+
|
|
8
|
+
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda:drop-terms');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const defaultConfig = {
|
|
12
|
+
'constraints': [
|
|
13
|
+
{'tag': '648', 'lex': 'yso/fin'},
|
|
14
|
+
{'tag': '648', 'lex': 'yso/swe'},
|
|
15
|
+
{'tag': '650', 'lex': 'yso/fin'},
|
|
16
|
+
{'tag': '650', 'lex': 'yso/swe'},
|
|
17
|
+
{'tag': '651', 'lex': 'yso/fin'},
|
|
18
|
+
{'tag': '651', 'lex': 'yso/swe'},
|
|
19
|
+
{'tag': '655', 'lex': 'slm/fin'},
|
|
20
|
+
{'tag': '655', 'lex': 'slm/swe'}
|
|
21
|
+
],
|
|
22
|
+
'keep invalid url': false, // If not true, removes illegal subfield $0. The whole field removal is later decided by 'keep 0-less'
|
|
23
|
+
'keep invalid label': false, // label ($a) is neither pref Label nor altLabel => remove whole field
|
|
24
|
+
'remove altLabel': false,
|
|
25
|
+
'remove 0-less': true
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default function (config = defaultConfig) {
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
description: 'Drop yso and slm terms that do not match their identifiers. Use for incoming records only! Not for records already in Melinda!',
|
|
32
|
+
validate, fix
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
async function fix(record, validateMode = false) {
|
|
36
|
+
const clonedFields = record.fields.map(f => clone(f));
|
|
37
|
+
|
|
38
|
+
const results = await processFields(clonedFields);
|
|
39
|
+
|
|
40
|
+
const removables = results.map((f, i) => !f ? record.fields[i] : undefined).filter(f => f);
|
|
41
|
+
const modMessages = results.map((f, i) => getMod(f, i)).filter(f => f);
|
|
42
|
+
const removalMessages = removables.map(f => `Remove '${fieldToString(f)}'`);
|
|
43
|
+
const allMessages = [...modMessages, ...removalMessages];
|
|
44
|
+
|
|
45
|
+
if (validateMode) {
|
|
46
|
+
if (allMessages.length === 0) {
|
|
47
|
+
return {'message': [], 'valid': true};
|
|
48
|
+
}
|
|
49
|
+
return {'message': allMessages, 'valid': false};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
removables.forEach(f => record.removeField(f));
|
|
53
|
+
|
|
54
|
+
return {message: [], fix: allMessages, valid: true};
|
|
55
|
+
|
|
56
|
+
function getMod(field, index) {
|
|
57
|
+
if (!field) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
const before = fieldToString(record.fields[index]);
|
|
61
|
+
const after = fieldToString(results[index]);
|
|
62
|
+
if (before !== after) {
|
|
63
|
+
if (!validateMode) {
|
|
64
|
+
record.fields[index] = field;
|
|
65
|
+
}
|
|
66
|
+
return `Modify '${before}' => '${after}'`;
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function isPotentialField(f) {
|
|
73
|
+
if (!config || !config.constraints) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return config.constraints.some(c => c.tag === f.tag && f.subfields?.some(sf => sf.code === '2' && sf.value === c.lex));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function validate(record) {
|
|
80
|
+
return fix(record, true);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
async function processFields(fields, results = []) {
|
|
85
|
+
const [currField, ...remainingFields] = fields;
|
|
86
|
+
if (!currField) {
|
|
87
|
+
return results;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!isPotentialField(currField)) { // Not interested in this field
|
|
91
|
+
return processFields(remainingFields, [...results, currField]);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
removeSyntacticallyIllegalSubfield0s(currField); // iff config wants them to be removed...
|
|
95
|
+
|
|
96
|
+
const removable = await isRemovableField(currField);
|
|
97
|
+
|
|
98
|
+
return processFields(remainingFields, [...results, removable ? undefined : currField]);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function removeSyntacticallyIllegalSubfield0s(field) {
|
|
102
|
+
if (config['keep invalid url']) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const lexData = getLexiconAndLanguage(field);
|
|
107
|
+
if (!lexData.lang) { // This is an error of sorts. Should we proceed and remove $0s?
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
field.subfields = field.subfields.filter(sf => sf.code !== '0' || isValidSubfield0(sf, lexData.lex));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function isRemovableField(field) {
|
|
115
|
+
// nvdebug(`FOO===== ${fieldToString(field)}`);
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
// $0-less field:
|
|
119
|
+
if (!field.subfields.some(sf => sf.code === '0')) {
|
|
120
|
+
return config['remove 0-less'];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const subfield0 = field.subfields.find(sf => sf.code === '0');
|
|
124
|
+
const data = await getTermData(subfield0.value);
|
|
125
|
+
// NB! No data might be a BUG! This might delete all incoming terms if Finto is down... (we should distinguish between a miss and a failure)
|
|
126
|
+
// However, if we use this validator only for incoming records, it's fine enough.
|
|
127
|
+
|
|
128
|
+
if (data) {
|
|
129
|
+
const subfieldA = field.subfields.find(sf => sf.code === 'a');
|
|
130
|
+
if (subfieldA) {
|
|
131
|
+
const lexData = getLexiconAndLanguage(field);
|
|
132
|
+
|
|
133
|
+
// $a is the pref label. All is fine!
|
|
134
|
+
if (isLabel(data.prefLabel, subfieldA.value, lexData.lang)) {
|
|
135
|
+
debug(`altLabel found: ${subfieldA.value}`);
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
if (isLabel(data.altLabel, subfieldA.value, lexData.lang)) {
|
|
139
|
+
debug(`altLabel found: ${subfieldA.value}`);
|
|
140
|
+
// Oddly enough this could remove altLabel but keep totally invalid labels...
|
|
141
|
+
return config['remove altLabel'];
|
|
142
|
+
}
|
|
143
|
+
debug(`a-2-0 mismatch: ${fieldToString(field)}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
if (config['keep invalid label']) {
|
|
149
|
+
// We keep the label $a. However, we can get rid of $0 if we want to (semantic reasons)
|
|
150
|
+
if (!config['keep invalid url']) {
|
|
151
|
+
nvdebug(`=============== 0-removal`);
|
|
152
|
+
field.subfields = field.subfields.filter(sf => sf.code !== '0');
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
//import createDebugLogger from 'debug';
|
|
3
|
+
import fetchMock from 'fetch-mock';
|
|
4
|
+
|
|
5
|
+
import validatorFactory from './drop-terms.js';
|
|
6
|
+
|
|
7
|
+
import {MarcRecord} from '@natlibfi/marc-record';
|
|
8
|
+
import {READERS} from '@natlibfi/fixura';
|
|
9
|
+
import generateTests from '@natlibfi/fixugen';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
import {fakeData} from '../test-fixtures/translate-terms-data.js';
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const uris = [
|
|
16
|
+
'http://www.yso.fi/onto/yso/p444',
|
|
17
|
+
'http://www.yso.fi/onto/yso/p500',
|
|
18
|
+
'http://www.yso.fi/onto/yso/p13299',
|
|
19
|
+
'http://www.yso.fi/onto/yso/p111739',
|
|
20
|
+
'http://www.yso.fi/onto/yso/p6197061979',
|
|
21
|
+
'http://www.yso.fi/onto/yso/p6196061969',
|
|
22
|
+
'http://urn.fi/URN:NBN:fi:au:slm:s161'
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const useMock = 1;
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
generateTests({
|
|
29
|
+
callback,
|
|
30
|
+
path: [import.meta.dirname, '..', 'test-fixtures', 'drop-terms'],
|
|
31
|
+
useMetadataFile: true,
|
|
32
|
+
recurse: false,
|
|
33
|
+
fixura: {
|
|
34
|
+
reader: READERS.JSON
|
|
35
|
+
},
|
|
36
|
+
hooks: {
|
|
37
|
+
before: async () => {
|
|
38
|
+
|
|
39
|
+
if (useMock) {
|
|
40
|
+
fetchMock.mockGlobal()
|
|
41
|
+
.get(`https://api.finto.fi/rest/v1/data?uri=${uris[0]}&format=application%2Fjson`, {status: 200, headers: {}, body: fakeData})
|
|
42
|
+
.get(`https://api.finto.fi/rest/v1/data?uri=${uris[1]}&format=application%2Fjson`, {status: 200, headers: {}, body: fakeData})
|
|
43
|
+
.get(`https://api.finto.fi/rest/v1/data?uri=${uris[2]}&format=application%2Fjson`, {status: 200, headers: {}, body: fakeData})
|
|
44
|
+
.get(`https://api.finto.fi/rest/v1/data?uri=${uris[3]}&format=application%2Fjson`, {status: 200, headers: {}, body: fakeData})
|
|
45
|
+
.get(`https://api.finto.fi/rest/v1/data?uri=${uris[4]}&format=application%2Fjson`, {status: 200, headers: {}, body: fakeData})
|
|
46
|
+
.get(`https://api.finto.fi/rest/v1/data?uri=${uris[5]}&format=application%2Fjson`, {status: 200, headers: {}, body: fakeData})
|
|
47
|
+
.get(`https://api.finto.fi/rest/v1/data?uri=${uris[6]}&format=application%2Fjson`, {status: 200, headers: {}, body: fakeData});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
testValidatorFactory();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/drop-terms:test');
|
|
56
|
+
|
|
57
|
+
async function testValidatorFactory() {
|
|
58
|
+
const validator = await validatorFactory();
|
|
59
|
+
|
|
60
|
+
assert.equal(typeof validator, 'object');
|
|
61
|
+
assert.equal(typeof validator.description, 'string');
|
|
62
|
+
assert.equal(typeof validator.validate, 'function');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function callback({getFixture, fix = false, config = undefined}) {
|
|
66
|
+
const validator = await validatorFactory(config);
|
|
67
|
+
const record = new MarcRecord(getFixture('record.json'));
|
|
68
|
+
const expectedResult = getFixture('expectedResult.json');
|
|
69
|
+
// console.log(expectedResult); // eslint-disable-line
|
|
70
|
+
|
|
71
|
+
if (!fix) {
|
|
72
|
+
const result = await validator.validate(record);
|
|
73
|
+
assert.deepEqual(result, expectedResult);
|
|
74
|
+
const originalRecord = new MarcRecord(getFixture('record.json'));
|
|
75
|
+
assert.deepEqual(record, originalRecord); // Validation should not change the record
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const expectedResult2 = new MarcRecord(expectedResult);
|
|
79
|
+
await validator.fix(record);
|
|
80
|
+
assert.deepEqual(record, expectedResult2);
|
|
81
|
+
}
|
package/src/empty-fields.test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
3
|
-
import validatorFactory from '
|
|
3
|
+
import validatorFactory from './empty-fields.js';
|
|
4
4
|
import {after, before, describe, it} from 'node:test';
|
|
5
5
|
|
|
6
6
|
before(() => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
3
|
-
import validatorFactory from '
|
|
3
|
+
import validatorFactory from './ending-punctuation.js';
|
|
4
4
|
import {describe, it} from 'node:test';
|
|
5
5
|
|
|
6
6
|
|
|
@@ -1598,7 +1598,7 @@ describe('ending-punctuation', () => {
|
|
|
1598
1598
|
]
|
|
1599
1599
|
},
|
|
1600
1600
|
{ // Exception: term ending in dot:
|
|
1601
|
-
tag
|
|
1601
|
+
tag: '648',
|
|
1602
1602
|
ind1: ' ',
|
|
1603
1603
|
ind2: '7',
|
|
1604
1604
|
subfields: [
|
|
@@ -1628,15 +1628,19 @@ describe('ending-punctuation', () => {
|
|
|
1628
1628
|
const recordValid650FinNo = new MarcRecord({
|
|
1629
1629
|
leader: '',
|
|
1630
1630
|
fields: [
|
|
1631
|
-
{
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1631
|
+
{
|
|
1632
|
+
tag: '650', ind1: ' ', ind2: '7', subfields: [
|
|
1633
|
+
{code: 'a', value: 'kirjastot'},
|
|
1634
|
+
{code: 'x', value: 'atk-järjestelmät'},
|
|
1635
|
+
{code: '2', value: 'kauno/fin'}
|
|
1636
|
+
]
|
|
1637
|
+
},
|
|
1638
|
+
{
|
|
1639
|
+
tag: '650', ind1: ' ', ind2: '7', subfields: [
|
|
1640
|
+
{code: 'a', value: 'ajovalot'},
|
|
1641
|
+
{code: '2', value: 'juho'}
|
|
1642
|
+
]
|
|
1643
|
+
}
|
|
1640
1644
|
]
|
|
1641
1645
|
});
|
|
1642
1646
|
|
|
@@ -1765,15 +1769,19 @@ describe('ending-punctuation', () => {
|
|
|
1765
1769
|
const recordInvalid650FinYes = new MarcRecord({
|
|
1766
1770
|
leader: '',
|
|
1767
1771
|
fields: [
|
|
1768
|
-
{
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1772
|
+
{
|
|
1773
|
+
tag: '650', ind1: ' ', ind2: '7', subfields: [
|
|
1774
|
+
{code: 'a', value: 'kirjastot'},
|
|
1775
|
+
{code: 'x', value: 'atk-järjestelmät.'},
|
|
1776
|
+
{code: '2', value: 'kauno/fin'}
|
|
1777
|
+
]
|
|
1778
|
+
},
|
|
1779
|
+
{
|
|
1780
|
+
tag: '650', ind1: ' ', ind2: '7', subfields: [
|
|
1781
|
+
{code: 'a', value: 'ajovalot.'},
|
|
1782
|
+
{code: '2', value: 'juho'}
|
|
1783
|
+
]
|
|
1784
|
+
}
|
|
1777
1785
|
]
|
|
1778
1786
|
});
|
|
1779
1787
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
3
|
-
import validatorFactory from '
|
|
3
|
+
import validatorFactory from './field-008-18-34-character-groups.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -19,7 +19,7 @@ generateTests({
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/field-008-18-34-character-groups:test');
|
|
22
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/field-008-18-34-character-groups:test');
|
|
23
23
|
|
|
24
24
|
async function testValidatorFactory() {
|
|
25
25
|
const validator = await validatorFactory();
|
|
@@ -30,12 +30,7 @@ async function testValidatorFactory() {
|
|
|
30
30
|
assert.equal(typeof validator.validate, 'function');
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
async function callback({getFixture,
|
|
34
|
-
if (enabled === false) {
|
|
35
|
-
debug('TEST SKIPPED!');
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
33
|
+
async function callback({getFixture, fix = false}) {
|
|
39
34
|
const validator = await validatorFactory();
|
|
40
35
|
const record = new MarcRecord(getFixture('record.json'));
|
|
41
36
|
const expectedResult = getFixture('expectedResult.json');
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './field-505-separators.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -19,7 +19,7 @@ generateTests({
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/field-505-separators:test');
|
|
22
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/field-505-separators:test');
|
|
23
23
|
|
|
24
24
|
async function testValidatorFactory() {
|
|
25
25
|
const validator = await validatorFactory();
|
|
@@ -29,12 +29,7 @@ async function testValidatorFactory() {
|
|
|
29
29
|
assert.equal(typeof validator.validate, 'function');
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
async function callback({getFixture,
|
|
33
|
-
if (enabled === false) {
|
|
34
|
-
debug('TEST SKIPPED!');
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
32
|
+
async function callback({getFixture, fix = false}) {
|
|
38
33
|
const validator = await validatorFactory();
|
|
39
34
|
|
|
40
35
|
const recordFixture = getFixture('record.json');
|
|
@@ -3,7 +3,7 @@ import {MarcRecord} from '@natlibfi/marc-record';
|
|
|
3
3
|
import validatorFactory from './field-521-fix.js';
|
|
4
4
|
import {READERS} from '@natlibfi/fixura';
|
|
5
5
|
import generateTests from '@natlibfi/fixugen';
|
|
6
|
-
import createDebugLogger from 'debug';
|
|
6
|
+
//import createDebugLogger from 'debug';
|
|
7
7
|
|
|
8
8
|
generateTests({
|
|
9
9
|
callback,
|
|
@@ -19,7 +19,7 @@ generateTests({
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/fix521:test');
|
|
22
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-validators-melinda/fix521:test');
|
|
23
23
|
|
|
24
24
|
async function testValidatorFactory() {
|
|
25
25
|
const validator = await validatorFactory();
|
|
@@ -29,12 +29,7 @@ async function testValidatorFactory() {
|
|
|
29
29
|
assert.equal(typeof validator.validate, 'function');
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
async function callback({getFixture,
|
|
33
|
-
if (enabled === false) {
|
|
34
|
-
debug('TEST SKIPPED!');
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
32
|
+
async function callback({getFixture, fix = false}) {
|
|
38
33
|
const validator = await validatorFactory();
|
|
39
34
|
const record = new MarcRecord(getFixture('record.json'));
|
|
40
35
|
const expectedResult = getFixture('expectedResult.json');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
3
|
-
import validatorFactory from '
|
|
3
|
+
import validatorFactory from './field-exclusion.js';
|
|
4
4
|
import {describe, it} from 'node:test';
|
|
5
5
|
|
|
6
6
|
// Factory validation
|
|
@@ -729,13 +729,15 @@ describe('field-exclusion', () => {
|
|
|
729
729
|
it('Finds the record invalid (spec)', async () => {
|
|
730
730
|
const validator = await validatorFactory(config);
|
|
731
731
|
const {valid, message} = await validator.validate(recordInvalidMulti);
|
|
732
|
-
assert.deepEqual({valid, message}, {
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
732
|
+
assert.deepEqual({valid, message}, {
|
|
733
|
+
valid: false, message: [
|
|
734
|
+
'Field $648 should be excluded',
|
|
735
|
+
'Field $650 should be excluded',
|
|
736
|
+
'Field $650 should be excluded',
|
|
737
|
+
'Field $651 should be excluded',
|
|
738
|
+
'Field $655 should be excluded'
|
|
739
|
+
]
|
|
740
|
+
});
|
|
739
741
|
});
|
|
740
742
|
|
|
741
743
|
it('Repairs invalid multi record', async () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
import {describe, it} from 'node:test';
|
|
3
3
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
4
|
-
import validatorFactory from '
|
|
4
|
+
import validatorFactory from './field-structure.js';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
// Factory validation
|