---
title: "MandatoryFieldGuard – API-Referenz · Quittio"
description: "Checks after rendering that the template printed all mandatory values."
canonical_url: "https://quittio.dev/docs/api/Quittio/Core/View/MandatoryFieldGuard"
locale: de
meta:
  "og:description": "Checks after rendering that the template printed all mandatory values."
  "og:image": "https://quittio.dev/og/quittio-de.jpg"
  "og:image:alt": "Quittio: E-Rechnungen für PHP und Laravel. Rechtssicher, validiert, archiviert, mit geprüfter Beispielrechnung."
  "og:image:height": "630"
  "og:image:type": image/jpeg
  "og:image:width": "1200"
  "og:title": "MandatoryFieldGuard – API-Referenz · Quittio"
  "twitter:image": "https://quittio.dev/og/quittio-de.jpg"
  "twitter:image:alt": "Quittio: E-Rechnungen für PHP und Laravel. Rechtssicher, validiert, archiviert, mit geprüfter Beispielrechnung."
---

> Index of every page on this site: [llms.txt](https://quittio.dev/llms.txt)

[API reference](https://quittio.dev/docs/api) / [Quittio](https://quittio.dev/docs/api/Quittio) \\ [Core](https://quittio.dev/docs/api/Quittio/Core) \\ [View](https://quittio.dev/docs/api/Quittio/Core/View)

# MandatoryFieldGuard

final class in quittio/core

`Quittio\Core\View\MandatoryFieldGuard` · [Source](https://github.com/Quittio/quittio/blob/v0.7.1/packages/core/src/View/MandatoryFieldGuard.php#L27)

Checks after rendering that the template printed all mandatory values.

A custom template could omit mandatory information (e.g. the VAT identifier); then PDF and XML would differ in content. Access keys are view model paths:

- "\[*]" stands for every index: "vatRows\[*].amount" requires the amount of every VAT row;
- "&" combines paths that must all be printed, "|" separates alternatives;
- a path counts only where the view model has a value: paths of null values and empty lists are not required, and a field whose alternatives all have no value is skipped.

Only printed leaf values count (see `ViewNode`).

## Constants \#

| Constant | Value | Description |
| --- | --- | --- |
| `LEGAL_NOTE_SUBJECTS` | `[\Quittio\Core\Enums\NoteSubjectCode::RegulatoryInformation, \Quittio\Core\Enums\NoteSubjectCode::LegalInformation, \Quittio\Core\Enums\NoteSubjectCode::TaxDecl …` | Note subjects (BT-21) that the view model lists in "legalNotes". |
| `MODE_EXCEPTION` | `'exception'` | |
| `MODE_LOG` | `'log'` | |
| `MODE_OFF` | `'off'` | |

## Methods \#

| Method | Description |
| --- | --- |
| `->__construct()` | |
| `::address()` | The address of a party: all address lines, or street, postcode and city. |
| `::baseFields()` | Fields every invoice PDF must show, independent of the country. |
| `->check()` | |
| `::notePath()` | View model path of the first note that matches, wherever the view model lists it: "legalNotes\[i]" for regulatory, legal and tax notes, otherwise "notes\[i].content\|notes\[i].html". |

### `__construct()`#

```
public function __construct(
    string $mode = self::MODE_EXCEPTION,
    ?LoggerInterface $logger = null,
)
```

| Parameter | Type | Description |
| --- | --- | --- |
| `$mode` | `string` = `self::MODE_EXCEPTION` | |
| `$logger` | `?Psr\Log\LoggerInterface` = `null` | |

### `address()`#

```
public static function address(string $party): string
```

static

The address of a party: all address lines, or street, postcode and city.

| Parameter | Type | Description |
| --- | --- | --- |
| `$party` | `string` | |

<dl><dt>Returns</dt>
<dd><code>string</code></dd>
</dl>

### `baseFields()`#

```
public static function baseFields(InvoiceData $invoice): MandatoryFieldList
```

static

Fields every invoice PDF must show, independent of the country.

| Parameter | Type | Description |
| --- | --- | --- |
| `$invoice` | `[InvoiceData](https://quittio.dev/docs/api/Quittio/Core/Data/InvoiceData)` | |

<dl><dt>Returns</dt>
<dd><code><a href="https://quittio.dev/docs/api/Quittio/Core/Countries/MandatoryFieldList">MandatoryFieldList</a></code></dd>
</dl>

### `check()`#

```
public function check(MandatoryFieldList $fields, AccessLog $log): list<MandatoryField>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `$fields` | `[MandatoryFieldList](https://quittio.dev/docs/api/Quittio/Core/Countries/MandatoryFieldList)` | |
| `$log` | `[AccessLog](https://quittio.dev/docs/api/Quittio/Core/View/AccessLog)` | |

<dl><dt>Returns</dt>
<dd><code>list&lt;<a href="https://quittio.dev/docs/api/Quittio/Core/Countries/MandatoryField">MandatoryField</a>&gt;</code> – fields that were not printed</dd></dl>

### `notePath()`#

```
public static function notePath(InvoiceData $invoice, callable $matches): ?string
```

static

View model path of the first note that matches, wherever the view model lists it: "legalNotes\[i]" for regulatory, legal and tax notes, otherwise "notes\[i].content|notes\[i].html".

| Parameter | Type | Description |
| --- | --- | --- |
| `$invoice` | `[InvoiceData](https://quittio.dev/docs/api/Quittio/Core/Data/InvoiceData)` | |
| `$matches` | `callable` | |

<dl><dt>Returns</dt>
<dd><code>?string</code></dd>
</dl>

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://quittio.dev/#website","@type":"WebSite","description":"E-Rechnungen für PHP und Laravel: ZUGFeRD, XRechnung und Peppol erstellen, prüfen, lesen und archivieren.","inLanguage":"de-DE","name":"Quittio","url":"https://quittio.dev/","publisher":{"@id":"https://quittio.dev/#identity"},"workTranslation":{"@id":"https://quittio.dev/en#website"}},{"@id":"https://quittio.dev/docs/api/Quittio/Core/View/MandatoryFieldGuard#webpage","@type":"WebPage","description":"Checks after rendering that the template printed all mandatory values.","name":"MandatoryFieldGuard – API-Referenz","url":"https://quittio.dev/docs/api/Quittio/Core/View/MandatoryFieldGuard","isPartOf":{"@id":"https://quittio.dev/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://quittio.dev/docs/api/Quittio/Core/View/MandatoryFieldGuard"]}],"primaryImageOfPage":{"@id":"https://quittio.dev/#logo"}},{"@id":"https://quittio.dev/#identity","@type":"Organization","description":"Open-Source-Bibliothek für E-Rechnungen in PHP und Laravel (ZUGFeRD, XRechnung, Peppol) und Quittio Managed.","email":"kontakt@niklasforst.de","legalName":"Niklas Forst – Softwareentwicklung","name":"Quittio","url":"https://quittio.dev","founder":{"@type":"Person","name":"Niklas Forst","url":"https://quittio.dev/ueber"},"logo":{"@id":"https://quittio.dev/#logo"},"sameAs":["https://github.com/Quittio/quittio","https://packagist.org/packages/quittio/quittio"]},{"@id":"https://quittio.dev/#logo","@type":"ImageObject","caption":"Quittio","contentUrl":"https://quittio.dev/logo.png","inLanguage":"de-DE","url":"https://quittio.dev/logo.png"}]}
```