FormattedString

The FormattedString field allows you to generate a string that is formatted according to a template, see Templating. Templates are quite powerful and allow you to generate a wide variety of data. For example, you could generate a string that is a combination of a first name, last name and a random number, e.g. John Smith 1234.

Schema

fields:
  - name: A
    type: Digit
  - name: B
    type: FormattedString
    args:
      format: |
        Doing math (A + 4): {{ refs['A'].raw + 4}}!
        Accessing values: {{ refs['C'].raw }}!
        Formatting dates: {{ refs['D'].raw | date(format="%Y-%m-%d") }}
    constraints:
      - type: IfNull
        name: C
  - name: C
    type: Digit
    null_probability: 0.5
  - name: D
    type: DateTime

Output

ABCD
442667-11-04T03:14:00+00:00
9Doing math (A + 4): 13!
Accessing values: !
Formatting dates: 2603-05-24
2603-05-24T15:36:00+00:00
042312-12-06T02:40:00+00:00
0Doing math (A + 4): 4!
Accessing values: !
Formatting dates: 2910-06-24
2910-06-24T13:18:00+00:00
0Doing math (A + 4): 4!
Accessing values: !
Formatting dates: 2807-02-22
2807-02-22T18:16:00+00:00

Arguments

NameTypeDescriptionDefault Value
formatstringThe format of the string. See Templating for more info.

Field arguments

NameTypeDescriptionDefault Value
null_probabilityfloatThe probability that the field will be null.0.0
constraintslistA list of constraints to apply to the field.[]

Supported constraints

NameDescription
IfNullThe value must only be non-null if another field is null.