Number/String Data Type

An str_number data type tests data for being an instance of python's built-in class int, float or class str and string must represent an integer or a float value.

String is converted to float if representing an float value or to int if representing a integer value Use convert_to option to enforce convertion to other data types.

Features/Limitations

  • Validate minimal and maximal number value
  • Validate against allowed and not allowed value ranges
  • Validate against allowed and not allowed number values
  • Validate if float value meets allowed accuracy
  • Conversion supports rounding the float value
  • Supports Referencing Feature

Number/String Definition Syntax

Table

Key/Option Type Default Value Restrictions Description
type str 'str_number'
description str Data type description
default_value Must match data type's type(s) Value used to set as default value
convert_to str Allowed values:
- float
- int
- str
minimum float|int|str Value must be greater or equal
maximum float|int|str >= 'minimum' Value must be lower or equal
allowed_ranges list[dict] min length: 1 Value must be within defined ranges
  - start float|int|str required
    end float|int|str required
not_allowed_ranges list[dict] Value mustn't be within defined ranges
  - start float|int|str required
    end float|int|str required
allowed_values list Data must match one of these values
  - < value > float|int|str Must match data type's type(s)
not_allowed_values list Data mustn't match all of these values
  - < value > float|int|str Must match data type's type(s)
maximum_decimals int Must be >= 0 and <= 17 Value's accuracy must be lower or equal
round_to_decimals int Must be >= 0 and <= 17 Convert value to this accuracy
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: str_number
description: <str>
default_value: <default_value>

convert_to: <float|int|str>
maximum: <float|int|str>
minimum: <float|int|str>
allowed_ranges:
 - start: <float|int|str>
   end: <float|int|str>
not_allowed_ranges:
 - start: <float|int|str>
   end: <float|int|str>
allowed_values:
  - <float|int|str>
not_allowed_values:
  - <float|int|str>
maximum_decimals: <int>
round_to_decimals: <int>

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: str_number
description: "Example str_number definition"

minimum: 1
maximum: 3.0

not_allowed_values:
  - 3.0
  - 1
  - "0.9"
  - "4"

reference: ref_key