Skip to content

Subfield exclusion

natlibfi-arlehiko edited this page Sep 7, 2018 · 2 revisions

Description

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

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

Configuration

An array of object with the following properties:

  • tag (RegExp): Pattern to match the field's tags Mandatory
  • ind1 (RegExp): Pattern to match the field's ind1 property
  • ind2 (RegExp): Pattern to match the field's ind2 property
  • subfields (Array<Object>): An array of objects with the following properties (Mandatory):
    • code (RegExp): Pattern to match the subfield's code Mandatory
    • value (RegExp): Pattern to match the subfield's value

Examples

Simple configuration

Configuration

[{
  tag: /^100$/,
  subfields: [{code: /4/}]
}]

Valid record

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

Invalid record

{
  "leader": "foo",
  "fields": [
    {
      "tag": "100",
      "ind1": " ",
      "ind2": " ",
      "subfields": [
        {
          "code": "a",
          "value": "Foo Bar"
        },
        {
          "code": "4",
          "value": "att"
        }
      ]
    },
    {
      "tag": "245",
      "ind1": " ",
      "ind2": " ",
      "subfields": [
        {
          "code": "a",
          "value": "Fubar"
        }
      ]
    }
  ]
}

Complex configuration

Configuration

[{
  tag: /^210$/,
  ind2: /\s/,
  subfields: [{
    code: /2/,
    value: /.+/
  }]
}]

Valid record

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

Invalid record

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