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
| A | B | C | D |
|---|---|---|---|
| 4 | 4 | 2667-11-04T03:14:00+00:00 | |
| 9 | Doing math (A + 4): 13! Accessing values: ! Formatting dates: 2603-05-24 | 2603-05-24T15:36:00+00:00 | |
| 0 | 4 | 2312-12-06T02:40:00+00:00 | |
| 0 | Doing math (A + 4): 4! Accessing values: ! Formatting dates: 2910-06-24 | 2910-06-24T13:18:00+00:00 | |
| 0 | Doing math (A + 4): 4! Accessing values: ! Formatting dates: 2807-02-22 | 2807-02-22T18:16:00+00:00 |
Arguments
| Name | Type | Description | Default Value |
|---|---|---|---|
| format | string | The format of the string. See Templating for more info. |
Field arguments
| Name | Type | Description | Default Value |
|---|---|---|---|
| null_probability | float | The probability that the field will be null. | 0.0 |
| constraints | list | A list of constraints to apply to the field. | [] |
Supported constraints
| Name | Description |
|---|---|
| IfNull | The value must only be non-null if another field is null. |