Multitype2 Data Type
A multitype2 data type represents a selection of different data types. It test data for being a valid input for a listed data type definition - one by one. If a data type definition matches, a requested preprocessing is applied. If no data type definition matches, the multitype2 data type doesn't match and validation fails.
Note: multitype2 relaxes restrictions of multitype but loses details why a validation fails.
Features/Limitations
- Overlapping python class matching among listed data types is supported.
- Nesting multitype or multitype2 in multitype2 is supported.
- Data type conversion is not supported. Use conversion within listed data types instead.
Multitype2 Definition Syntax
Table
| Key/Option | Type | Default Value | Restrictions | Description |
|---|---|---|---|---|
| type | str |
'multitype2' | ||
| description | str |
Data type description | ||
| default_value | Must match data type's type(s) | Value used to set as default value | ||
| types | list[dict|str] |
required min length: 1 |
List of type definitions | |
| - |
dict|str |
|||
| option 1 | str |
Data type string (short definition) | ||
| option 2 | dict |
Data type definition | ||
| template | str |
must be definded in schema | Merge options from this template | |
| template_merge_options | dict |
Define schema-global template merge instructions | ||
| recursive | bool |
True |
Merge data type definition options in template options recursively. If false, data type defintion options overwrites template options. |
|
| list_merge | str |
append_rp | Allowed values: - append - append_rp - prepend - prepend_rp - replace |
How lists within options data should be merged. |
| reference | dict|str |
|||
| option 1 | str |
Reference keys (implies unique global mode) | ||
| option 2 | dict |
|||
| key | str |
required | ||
| mode | str |
Allowed values: - unique - producer - consumer |
||
| unique_scope | str |
Allowed values: - global - namespace |
||
| producer_scope | str |
Allowed values: - global - namespace |
||
| consumer_scope | str |
Allowed values: - global - namespace |
||
| allow_orphan_producer | bool |
True |
||
| credit | int |
1 (if mode consumer) | min: 0 | |
| references | list[dict|str] |
|||
| - |
dict|str |
|||
| option 1 | str |
Reference keys (implies unique global mode) | ||
| option 2 | dict |
|||
| key | str |
required | ||
| mode | str |
Allowed values: - unique - producer - consumer |
||
| unique_scope | str |
Allowed values: - global - namespace |
||
| producer_scope | str |
Allowed values: - global - namespace |
||
| consumer_scope | str |
Allowed values: - global - namespace |
||
| allow_orphan_producer | bool |
True |
||
| credit | int |
1 (if mode consumer) | min: 0 | |
| doc_value_name | str |
Set value name for documentation |
YAML
type: multitype2
description: <str>
default_value: <default_value>
types:
- <dict|str>
# Mulitype!!!
<str>
# or
<dict>
template: <str>
template_merge_options:
recursive: <true|false>
list_merge: <append|append_rp|prepend|prepend_rp|replace>
reference: <reference_definition>
# Multitype!!!
<str>
# or:
key: <str>
mode: <unique|producer|consumer>
unique_scope: <global|namespace>
producer_scope: <global|namespace>
consumer_scope: <global|namespace>
allow_orphan_producer: <true|false>
credits: <int>
references:
- <reference_definition>
# Multitype!!!
<str>
# or
key: <str>
mode: <unique|producer|consumer>
unique_scope: <global|namespace>
producer_scope: <global|namespace>
consumer_scope: <global|namespace>
allow_orphan_producer: <true|false>
credits: <int>
doc_value_name: <str>
Example
type: multitype2
description: "Example multitype2 definition"
default_value: 0
types:
- type: int
reference: ref_key
- type: str
minimum: 4
not_allowed_values:
- 'test'
reference: ref_key
- type: str
minimum: 2
not_allowed_values:
- 'me'
reference: ref_key