> ## Documentation Index
> Fetch the complete documentation index at: https://iso8583sim.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Types

> iso8583sim.core.types

`iso8583sim.core.types`

## `ISO8583Version`

Bases: `Enum`

ISO 8583 protocol versions

| Member | Value |
| - | - |

\| `V1987` | `'1987'` |
\| `V1993` | `'1993'` |
\| `V2003` | `'2003'` |

## `FieldType`

Bases: `Enum`

Field data types in ISO 8583

| Member | Value |
| - | - |

\| `NUMERIC` | `'n'` |
\| `ALPHA` | `'a'` |
\| `ALPHANUMERIC` | `'an'` |
\| `BINARY` | `'b'` |
\| `SPECIAL` | `'s'` |
\| `TRACK2` | `'z'` |
\| `LLVAR` | `'ll'` |
\| `LLLVAR` | `'lll'` |

## `CardNetwork`

Bases: `Enum`

Card network identifiers

| Member | Value |
| - | - |

\| `VISA` | `'VISA'` |
\| `MASTERCARD` | `'MASTERCARD'` |
\| `AMEX` | `'AMEX'` |
\| `DISCOVER` | `'DISCOVER'` |
\| `JCB` | `'JCB'` |
\| `UNIONPAY` | `'UNIONPAY'` |

## `MessageClass`

Bases: `Enum`

Message class identifiers (position 2 of MTI)

| Member | Value |
| - | - |

\| `AUTHORIZATION` | `'1'` |
\| `FINANCIAL` | `'2'` |
\| `FILE_ACTIONS` | `'3'` |
\| `REVERSAL` | `'4'` |
\| `RECONCILIATION` | `'5'` |
\| `ADMINISTRATIVE` | `'6'` |
\| `FEE_COLLECTION` | `'7'` |
\| `NETWORK_MANAGEMENT` | `'8'` |

## `MessageFunction`

Bases: `Enum`

Message function identifiers (position 3 of MTI)

| Member | Value |
| - | - |

\| `REQUEST` | `'0'` |
\| `RESPONSE` | `'1'` |
\| `ADVICE` | `'2'` |
\| `ADVICE_RESPONSE` | `'3'` |
\| `NOTIFICATION` | `'4'` |
\| `NETWORK_REQUEST` | `'8'` |
\| `NETWORK_RESPONSE` | `'9'` |

## `MessageOrigin`

Bases: `Enum`

Message origin identifiers (position 4 of MTI)

| Member | Value |
| - | - |

\| `ACQUIRER` | `'0'` |
\| `ACQUIRER_REPEAT` | `'1'` |
\| `ISSUER` | `'2'` |
\| `ISSUER_REPEAT` | `'3'` |
\| `OTHER` | `'4'` |
\| `OTHER_REPEAT` | `'5'` |

## `FieldDefinition`

```python theme={null}
FieldDefinition(
    field_type: FieldType,
    max_length: int,
    description: str,
    field_number: int | None = None,
    encoding: str = 'ascii',
    min_length: int | None = None,
    padding_char: str | None = None,
    padding_direction: str = 'left',
)
```

Definition of an ISO 8583 field

## `ISO8583Message`

```python theme={null}
ISO8583Message(
    mti: str,
    fields: dict[int, str],
    version: ISO8583Version = ISO8583Version.V1987,
    network: CardNetwork | None = None,
    raw_message: str | None = None,
    bitmap: str | None = None,
)
```

Represents a complete ISO 8583 message

### `message_class`

Get message class from MTI

### `message_function`

Get message function from MTI

### `message_origin`

Get message origin from MTI

## `ISO8583Error`

Bases: `Exception`

Base exception for ISO 8583 errors

## `ParseError`

Bases: `ISO8583Error`

Raised when parsing fails

## `ValidationError`

Bases: `ISO8583Error`

Raised when validation fails

## `BuildError`

Bases: `ISO8583Error`

Raised when message building fails

## Functions

### `get_field_definition()`

```python theme={null}
def get_field_definition(
    field_number: int,
    network: CardNetwork | None = None,
    version: ISO8583Version = ISO8583Version.V1987,
) -> FieldDefinition | None
```

Get field definition considering network and version specifics.

**Parameters**

<ResponseField name="field_number" type="int" required>
  The field number to look up
</ResponseField>

<ResponseField name="network" type="CardNetwork | None" default="None">
  Optional card network for network-specific definitions
</ResponseField>

<ResponseField name="version" type="ISO8583Version" default="ISO8583Version.V1987">
  ISO8583 version
</ResponseField>

<ResponseField name="Returns" type="FieldDefinition | None">
  FieldDefinition if found, None otherwise
</ResponseField>

Priority order:

1. Network-specific definition
2. Version-specific definition
3. Standard field definition

Note: Results are cached for performance (lru\_cache with 512 entries).

### `is_valid_mti()`

```python theme={null}
def is_valid_mti(mti: str) -> bool
```

Check if MTI is valid.

**Parameters**

<ResponseField name="mti" type="str" required>
  Message Type Indicator string
</ResponseField>

<ResponseField name="Returns" type="bool">
  True if MTI is valid, False otherwise
</ResponseField>

Validates:

* Length is 4 digits
* All characters are numeric
* Each position contains valid values

### `get_network_required_fields()`

```python theme={null}
def get_network_required_fields(network: CardNetwork) -> list[int]
```

Get list of required fields for a specific network.

**Parameters**

<ResponseField name="network" type="CardNetwork" required>
  Card network
</ResponseField>

<ResponseField name="Returns" type="list[int]">
  List of required field numbers
</ResponseField>

### `get_field_format_pattern()`

```python theme={null}
def get_field_format_pattern(network: CardNetwork, field_number: int) -> str | None
```

Get network-specific field format pattern.

**Parameters**

<ResponseField name="network" type="CardNetwork" required>
  Card network
</ResponseField>

<ResponseField name="field_number" type="int" required>
  Field number
</ResponseField>

<ResponseField name="Returns" type="str | None">
  Regex pattern string if exists, None otherwise
</ResponseField>

### `is_binary_field()`

```python theme={null}
def is_binary_field(field_def: FieldDefinition) -> bool
```

Check if field is binary type.

**Parameters**

<ResponseField name="field_def" type="FieldDefinition" required>
  Field definition
</ResponseField>

<ResponseField name="Returns" type="bool">
  True if field is binary, False otherwise
</ResponseField>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.