@String()
New in 2.0Generate random strings
Data TypesSince 2.0.0
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| length | — | — | String length, default 6, max length 2^31-1 characters | |
| min | — | — | Minimum length, default 0 (returns empty string "") when not specified. If length is specified, this parameter is ignored | |
| max | — | — | Maximum length, max limit 2^31-1 characters. If length is specified, this parameter is ignored | |
| chars | — | — | Character set for string generation. Default: 52 letters (a-z A-Z) and 10 digits (0-9). Max 2^31-1 characters, e.g.: 123456ABCDEF | |
| nullSampler | — | — | The null ratio, such as "1:2", indicates that generating a random value 3 times with an average of 1 time is null |
Usage
@String(arg0,arg1,arg2,arg3,arg4)Full parameter constructor, see complete parameter documentation
Example:
@String(1,,,ABCDE,"1:2")
Output:
AnullBCnull@String(arg0,arg1)Generate random string within specified length range
Example:
@String(2,6)
Output:
ht8utcy@String(arg0,arg1,arg2)Generate fixed-length string from custom character set with null ratio
Example:
@String(3,"1:2",abcdef123456)
Output:
ec2f36c3a@String()Generate 6-character fixed-length random string
Example:
@String()
Output:
ceja7d@String(arg0)Generate fixed-length string
Example:
@String(2)
Output:
uyh8@String(arg0,arg1)Generate variable-length string within specified range with null ratio
Example:
@String(3,"1:2")
Output:
ec2nullc3a