Skip to content

Validations

Aaron Helton edited this page Nov 9, 2022 · 3 revisions

Files

Description: Provides a framework for validating MARC records according to an expressive validation configuration.

Structure: validation.js exports a validationData object consisting of top-level collection objects (keys: bibs, auths, speeches, and votes) that. Each collection object contains a list of keyed field objects, e.g., "020" representing the MARC fields that are valid for that collection. Each field object contains a list of keyed properties:

  • name (String) : The name of the field.
  • required (Boolean) : Whether the field is required or not.
  • repeatable (Boolean) : Whether the field can be repeated in the record.
  • validIndicators1 (Array) : A list of strings that are allowed in the first indicator position. Currently, blank values are denoted with underscore ("_"). An empty array means that only a blank value is allowed. An asterisk ("*") means that any value is allowed.
  • validIndicators2 (Array) : A list of strings that are allowed in the second indicator position. Currently, blank values are denoted with underscore ("_"). An empty array means that only a blank value is allowed. An asterisk ("*") means that any value is allowed.
  • requiredSubfields (Array) : A list of strings corresponding to subfield codes that are required to save the record. Records that include this field but are missing any required subfields will fail to save.
  • validSubfields (Array) : A list of strings corresponding to subfield codes that are allowed on the field. Records that include this field and any field not in this list will fail to save.
  • defaultSubfields (Array) : A list of strings corresponding to subfield codes that will be added to the field automatically in the record editor.
  • validStrings (Object) : An object whose keys correspond to subfield codes for subfields whose values must match the accompanying list of strings.
  • isDate (Object) : An object whose keys correspond to subfield codes for subfields whose values must be a valid date.

Here is a sample validation set:

"[collection]": {
  "[field]": {
    "name": "A MARC Field",
    "required": false,
    "repeatable": true,
    "validIndicators1": [],
    "validIndicators2": [],
    "requiredSubfields": [],
    "validSubfields": ["a","b"],
    "defaultSubfields": ["a"],
    "validStrings: {
      "b": ["string1", "string2"]
    },
    "isDate": {
      "a": true
    }
  }
}
Clone this wiki locally