String Data Type

A str data type tests data for being an instance of python's built-in class str.

If using str data type without regex mode, allowed values and no conversion defined, check enum data type as a better option.

Features/Limitations

  • Validate string length
  • Validate against allowed and not allowed strings
  • Regex Mode validates data strings based on regex patterns.
  • Supports Referencing Feature. Adds an option to lookup values in other namespaces.
  • Data type conversion is not supported

String Definition Syntax

Table

Key/Option Type Default Value Restrictions Description
type str 'str'
description str Data type description
default_value Must match data type's type(s) Value used to set as default value
minimum int min: 1 Data's length must be greater or equal
maximum int min: 1
>= 'minimum'
Data's length must be lower or equal
regex_mode bool False Enable testing strings against regex strings
regex_fullmatch bool True Full string must match
regex_multiline bool False Regex ^ and $ matches to newline character
replace_empty_to any An empty input value will be replaced by this data
allowed_values list[str] Data must match one of these strings/regex strings
  - < str > str
not_allowed_values list[str] Data mustn't match any of these strings/regex strings
  - < str > str
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
  namespace_separator_char str length must be 1
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
    namespace_separator_char str length must be 1
doc_value_name str Set value name for documentation

YAML

type: str
description: <str>
default_value: <default_value>

maximum: <int>
minimum: <int>
regex_mode: <true|false>
regex_fullmatch: <true|false>
regex_multiline: <true|false>
replace_empty_to: <any>
allowed_values:
  - <str>
not_allowed_values:
  - <str>

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>
  namespace_separator_char: <str>
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>
    namespace_separator_char: <str>

doc_value_name: <str>

Example

type: str
description: "Example str definition with regex mode disabled"
default_value: "Hello World!"

minimum: 3
maximum: 15

not_allowed_values:
  - nadap sucks!

reference: ref_key

Example with regex mode enabled:

type: str
description: "Example str definition with regex mode enabled and namespace lookup"

minimum: 4
maximum: 15

regex_mode: true
allowed_values:
  - '[a-z_\.]*'
not_allowed_values:
  - \d+.*

reference:
  key: ref_key
  mode: consumer
  namespace_separator_char: '.'