Skip to content

Commit 1d1e8b1

Browse files
committed
Rebased and updated usage
1 parent be0785c commit 1d1e8b1

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
@@ -158,8 +158,9 @@ Structure `models[*].columns[*].type_params` for data type `string`:
158158
- `min_length`: Minimum string length. Default is `1`.
159159
- `max_length`: Maximum string length. Default is `32`.
160160
- `logical_type`: Logical type of string. Supported values: `first_name`, `last_name`, `phone`, `text`.
161-
- `template`: Template for string generation. Symbol `A` - any uppercase letter, symbol `a` - any lowercase letter,
162-
symbol `0` - any digit, symbol `#` - any character. Other characters remain as-is.
161+
- `template`: Jinja-like template for string generation. Allows you to use any fields of the generated model and
162+
specify the pattern of the string using the `pattern` function. Information about the filters and functions
163+
available in template strings is described at the end of this section.
163164
- `locale`: Locale for generated strings. Supported values: `ru`, `en`. Default is `en`.
164165
- `without_large_letters`: Flag indicating if uppercase letters should be excluded from the string.
165166
- `without_small_letters`: Flag indicating if lowercase letters should be excluded from the string.
@@ -240,6 +241,18 @@ Structure of `output.params` for `tcs` format:
240241
Similar to the structure for the `http` format,
241242
except that the `format_template` field is immutable and always set to its default value.
242243

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

245258
Example data model configuration:
@@ -305,9 +318,13 @@ models:
305318
- name: passport
306319
type: string
307320
type_params:
308-
template: AA 00 000 000
321+
template: "{{ pattern('AA 00 000 000') }}"
309322
distinct_percentage: 1
310323
ordered: true
324+
- name: email
325+
type: string
326+
type_params:
327+
template: "{{ first_name_en | lower }}.{{ id }}@example.com"
311328
- name: rating
312329
type: float
313330
type_params:

doc/ru/usage.md

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

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

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

0 commit comments

Comments
 (0)