MARC record validation
This project contains the software to run MARC validators. For the actual validators, see marc-record-validators-melinda.
See the wiki on how to write validators.
Usage
When the validate function is called on a MARC record (Implemented by marc-record-js) each enabled validator is ran to provide information about the record's validity. The validators can also fix warnings returned by the validator, if enabled.
The function resolves (Using a Promise) with an object which contains the validator messages and fix modifications:
"failed": false "validators": "name": "foo" "validate": "tag": "245" "messages": "type": "warning" "messages": "Has 'fu' instead of 'foo'" "fix": "tag": "245" "modifications": "type": "modifyField" "old": "tag": "245" "subfields": "code": "a" "value": "All is fubar" "new": "tag": "245" "subfields": "code": "a" "value": "All is foobar"
Node.js
validate = config return ;
AMD
;
Configuration
The configuration is passed as an object to the function returned by the factory. The following properties are supported:
- validators (array): An array of validator names or validator specification objects. The specified validators will be enabled. Defaults to empty (All validators enabled)
- failOnError (boolean): Throw an error immediately if a validator returns an error message. Defaults to true.
- fix (boolean): Whether to fix records which had any warnings (Returned by the validator). Defaults to false.
Development
Clone the sources and install the package using npm
:
npm install
Run the following NPM script to lint, test and check coverage of the code:
npm run check
License and copyright
Copyright (c) 2014-2016 University Of Helsinki (The National Library Of Finland)
This project's source code is licensed under the terms of GNU Affero General Public License Version 3 or any later version.