Skip to content

StringGenerator generator

Generate strings with configurable length, character set, uniqueness, prefix, and suffix.

Why: Use StringGenerator for bounded synthetic strings with an explicit alphabet and optional affixes; use RegexStringGenerator when the entire lexical shape is best expressed as a regular expression.

Category: core.

Output: str.

1
<key name="value" generator="StringGenerator(min_len=8, max_len=12, char_set='ABC123', prefix='T-', suffix='-X')"/>

Parameters

  • min_len: int | null; Default None β€” Inclusive minimum length of the generated body.
  • max_len: int | null; Default None β€” Inclusive maximum length of the generated body.
  • char_set: str | null; Default None β€” Non-empty alphabet sampled for the generated body.
  • unique: bool; Default False β€” Whether values must be unique within the supported in-process pool.
  • prefix: str | null; Default None β€” Constant text prepended to the generated body.
  • suffix: str | null; Default None β€” Constant text appended to the generated body.