Skip to content

Field exclusion

natlibfi-arlehiko edited this page Oct 1, 2018 · 3 revisions

Description

Checks that the record does not contain the configured fields. Fixes the record by removing the configured fields.

All rules must match for the field to be selected for exclusion.

Configuration

An array which can have following values as elements:

  • RegExp: Pattern for matching field tags
  • Object: An object with the following properties:
    • tag (RegExp): Pattern to match the field's tags Mandatory
    • value (RegExp): Regular expression object for matching a controlfields value. Mutual exclusive with the subfields, ind1 & ind2 properties.
    • ind1 (RegExp): Pattern to match the field's ind1 property. Mutual exclusive with the value property.
    • ind2 (RegExp): Pattern to match the field's ind2 property. Mutual exclusive with the value property.
    • subfields (Array<Object>): An array of objects with the following properties:
      • code (RegExp): Pattern to match the subfield's code Mandatory
      • value (RegExp): Pattern to match the subfield's value Mandatory
    • dependencies (Array<Object>): An array of objects with the following properties:
      • leader (RegExp): Pattern to match the record's leader

Examples

Simple configuration

Configuration

[{
  tag: /^500$/
}]

Valid record

{
  "leader": "foo",
  "fields": [
    {
      "tag": "245",
      "ind1": " ",
      "ind2": " ",
      "subfields": [
        {
          "code": "a",
          "value": "Fubar"
        }
      ]
    }
  ]
}

Invalid record

{
  "leader": "foo",
  "fields": [
    {
      "tag": "245",
      "ind1": " ",
      "ind2": " ",
      "subfields": [
        {
          "code": "a",
          "value": "Fubar"
        }
      ]
    },
    {
      "tag": "500",
      "ind1": " ",
      "ind2": " ",
      "subfields": [
        {
          "code": "a",
          "value": "Foo Bar Foo Bar Foo Bar"
        },
        {
          "code": "9",
          "value": "ALMA<KEEP>"
        }
      ]
    }
  ]
}

Complex configuration

Configuration

[
{
  tag: /^500$/,
  subfields: [{
    code: /9/,
    value: /^(?!FENNI<KEEP>).*$/ 
  }]
}]

Valid record

{
  "leader": "foo",
  "fields": [
    {
      "tag": "245",
      "ind1": " ",
      "ind2": " ",
      "subfields": [
        {
          "code": "a",
          "value": "Fubar"
        }
      ]
    },
    {
      "tag": "500",
      "ind1": " ",
      "ind2": " ",
      "subfields": [
        {
          "code": "a",
          "value": "Foo Bar Foo Bar Foo Bar"
        },
        {
          "code": "9",
          "value": "FENNI<KEEP>"
        }
      ]
    }
  ]
}

Invalid record

{
  "leader": "foo",
  "fields": [
    {
      "tag": "245",
      "ind1": " ",
      "ind2": " ",
      "subfields": [
        {
          "code": "a",
          "value": "Fubar"
        }
      ]
    },
    {
      "tag": "500",
      "ind1": " ",
      "ind2": " ",
      "subfields": [
        {
          "code": "a",
          "value": "Foo Bar Foo Bar Foo Bar"
        },
        {
          "code": "9",
          "value": "ALMA<KEEP>"
        }
      ]
    }
  ]
}