---
name: "Catmandu::Validator::MARC"
section: "3pm"
platform: "linux"
package: "libcatmandu-marc-perl"
version: "1.320-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Catmandu::Validator::MARC"
---

# Catmandu::Validator::MARC(3pm)

Validate MARC records against a MARC21 Schema

## NAME

Catmandu::Validator::MARC - Validate MARC records against a MARC21 Schema

## SYNOPSIS

In Perl code:

```
    use Catmandu::Validator::MARC;
    Catmandu::Validator::MARC;
    use DDP;

    # load default MARC schema
    my $validator = Catmandu::Validator::MARC->new();

    # ... or load custom MARC schema
    my $validator = Catmandu::Validator::MARC->new( schema => 'schema.json' );
    my $importer = Catmandu::Importer::MARC->new(
        file => 't/camel.mrc',
        type => "ISO"
    );
    $importer->each( sub {
        my $record = shift;
        unless($validator->validate($record)){
            p $_ for @{$validator->last_errors()};
        }
    });
```

In Catmandu Fix language:

```
    # reject all items not conforming to the default MARC schema
    select valid(., MARC)
    # reject all items not conforming to a custom MARC schema
    select valid(., MARC, schema: 'schema.json')
```

## DESCRIPTION

This Catmandu::Validator can be used to check MARC records against an MARC21 schema. For more information see MARC::Schema and "MARC21 structure in JSON" \<https://pkiraly.github.io/2018/01/28/marc21-in-json/\>.

See also Catmandu::Fix::validate, and Catmandu::Fix::Condition::valid for usage of validators in Catmandu Fix language.

## CONFIGURATION

- schema

  MARC Schema given as filename (JSON) or instance of MARC::Schema.

- ignore\_unknown\_fields

  Don't report fields not included in the schema.

- ignore\_unknown\_subfields

  Don't report subfields not included in the schema.

## AUTHOR

Johann Rolschewski,  \<jorol at cpan\>
