Skip to content

Commit 227c6fb

Browse files
committed
Rebased and updated usage
1 parent 24415d2 commit 227c6fb

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

doc/en/usage.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ Structure `models[*].columns[*].type_params` for data type `string`:
154154
- `min_length`: Minimum string length. Default is `1`.
155155
- `max_length`: Maximum string length. Default is `32`.
156156
- `logical_type`: Logical type of string. Supported values: `first_name`, `last_name`, `phone`, `text`.
157-
- `template`: Template for string generation. Symbol `A` - any uppercase letter, symbol `a` - any lowercase letter,
158-
symbol `0` - any digit, symbol `#` - any character. Other characters remain as-is.
157+
- `template`: Jinja-like template for string generation. Allows you to use any fields of the generated model and
158+
specify the pattern of the string using the `pattern` function. Information about the filters and functions
159+
available in template strings is described at the end of this section.
159160
- `locale`: Locale for generated strings. Supported values: `ru`, `en`. Default is `en`.
160161
- `without_large_letters`: Flag indicating if uppercase letters should be excluded from the string.
161162
- `without_small_letters`: Flag indicating if lowercase letters should be excluded from the string.
@@ -236,6 +237,18 @@ Structure of `output.params` for `tcs` format:
236237
Similar to the structure for the `http` format,
237238
except that the `format_template` field is immutable and always set to its default value.
238239

240+
Filters and functions used in template strings:
241+
242+
Template strings are implemented using the `pongo2` library, you can read
243+
all available filters and functions in the [pongo2](https://github.com/flosch/pongo2) repository.
244+
245+
In addition, `1` function has been added:
246+
247+
- pattern: allows you to create a string pattern using special characters.
248+
The `A` symbol is any capital letter, the `a` symbol is any small letter,
249+
symbol `0` is any digit, the `#` symbol is any character, and the other characters remain as they are.
250+
The function is available only in the `template` field of the `string` data type.
251+
239252
#### Examples of data generation configuration
240253

241254
Example data model configuration:
@@ -301,9 +314,13 @@ models:
301314
- name: passport
302315
type: string
303316
type_params:
304-
template: AA 00 000 000
317+
template: "{{ pattern('AA 00 000 000') }}"
305318
distinct_percentage: 1
306319
ordered: true
320+
- name: email
321+
type: string
322+
type_params:
323+
template: "{{ first_name_en | lower }}.{{ id }}@example.com"
307324
- name: rating
308325
type: float
309326
type_params:

doc/ru/usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ open_ai:
243243
Подобна структуре для формата `http`, за исключением того,
244244
что поле `format_template` неизменяемое и всегда равняется значению по умолчанию.
245245

246-
Фильтры и функции, используемые в шаблонных строках
246+
Фильтры и функции, используемые в шаблонных строках:
247247

248248
Шаблонные строки реализованы с использованием библиотеки `pongo2`, ознакомиться
249249
со всеми доступными фильтрами и функциями можно в репозитории [pongo2](https://github.com/flosch/pongo2).

0 commit comments

Comments
 (0)