Data Providers
Data providers are a set of constraints that instruct the generator to create meaningful data for a property, such as person names, addresses, emails, etc. The following data providers are available:
Provider Name | Category Name | Description |
---|---|---|
Name | name | A person name |
Address | address | An address |
An email | ||
Id | id | Id String |
IP Address | ip | IP4 address |
Text String | text | A line of formatted text |
Credit Card | credit_card | A credit card number |
The following sample files can be used to generate five records using each provider:
All data providers are defined with constraints of a category
type, which comprise four properties:
- name: [required] Data provider name.
- qualifier: [optional, available to some providers] It is used to extract certain parts of the generated data, such as first name, last name, etc.
- locale: [optional, available to some providers] It limits data generation to a specific locale.
- compoundId: [optional] Used to differentiate the same data provider within the same entity. If properties have the same category name and compoundId, the same value will be used, otherwise different values are generated. The default value is 0.
Data providers can be only applied to text properties. They will be ignored when applied to other data types.
Name Provider
This provider generates random person names:
- name: name
- locale: An IETF BCP 47 language tag string, such as
en-US
orja-JP
. The default isen-US
. - qualifier: If
firstname
orlastname
is not provided, it generates the full name.
- Create Full Name
- Create First Name
- Create Last Name
properties:
- name: "full_name_sample"
type: "text"
constraints:
- type: "category"
name: "name"
locale: "ja-JP"
properties:
- name: "first_name_sample"
type: "text"
constraints:
- type: "category"
name: "name"
qualifier: "firstname"
properties:
- name: "last_name_sample"
type: "text"
constraints:
- type: "category"
name: "name"
qualifier: "lastname"
Address Provider
This provider generates random address
- category: address
- locale: An IETF BCP 47 language tag string, such as
en-US
orja-JP
. The default isen-US
. - qualifier: It can be
street
,city
,state
,country
orzip
. Without qualifier value, full address is generated
- Create Full Address
- Create Street Address
properties:
- name: "full_address_sample"
type: "text"
constraints:
- type: "category"
name: "address"
locale: "zh-TW"
properties:
- name: "street_sample"
type: "text"
constraints:
- type: "category"
name: "address"
qualifier: "street"
Email Provider
This provider generates random email address.
- category: email
properties:
- name: "email_sample"
type: "text"
constraints:
- type: "category"
name: "email"
Our default Email provider generates Gmail type email addresses with four parts <prefix>.<suffix>@<domain>.<domain_type>
, e.g. sdfd.fds2@fesfs.com
- prefix: 3 to 8 character long random string
- suffix: 3 to 8 character long random string
- domain: 3 to 8 character long random string
- domain_type: random value from "com", "info", "org", "net", "inc", "app", "ai" or "io"
To further customize the email address, you can use functions provided by String Alternation.
Id Provider
This provider generates random ID string with given format, if no format is provided, it generates UUID
- category: id
- auxiliary constraints: format
properties:
- name: "id_sample"
type: "text"
constraints:
- type: "category"
name: "id"
Define Id Format
Id format can be defined by combining with "format" constraint. Two wildcards are supported: "?" and "#" where "?" represents a random letter and "#" represents a random digit
- Create Formatted ID 1
- Create Formatted ID 2
# it generates ID starting with "ID-" and ending with 10 random digits
properties:
- name: "id_formatted_1"
type: "text"
constraints:
- type: "category"
name: "id"
- type: "format"
format: "ID-##########"
# it generates ID starting with "2024.2." and ending with 3 random letters
properties:
- name: "id_formatted_1"
type: "text"
constraints:
- type: "category"
name: "id"
- type: "format"
format: "2024.2.???"
IP Address Provider
This provider generates random IP4 address
- category: ip
- auxiliary constraints: format
properties:
- name: "ip_address_sample"
type: "text"
constraints:
- type: "category"
name: "ip"
Define IP Address Masks
Ip address masks can be defined can be defined by combining with "format" constraint. Masks are defined as a list of strings, each string represents a mask. If more than 1 mask is defined, each mask is applied randomly. A mask consists with number parts and the wildcard character (#) parts
Examples:
- "172.0.###.###" - it generates IP addresses starting with 172.0
- "###.23.5.###" - it generates IP addresses with 23.5 in the middle
- "172.###.###.5" - it generates IP addresses starting with 172 and ending with 5
### Create IP address in the range between 172.0.0.0 and 172.1.255.255
properties:
- name: "masked_ip_address"
type: "text"
constraints:
- type: "category"
name: "ip"
- type: "format"
format: |
- "172.0.###.###"
- "172.1.###.###"
The format spec is parsed as YAML string in a separate process, please make sure pipe (|) character is at the beginning of the format string
Random Text String Provider
This provider generates random text string. By default the generated text is between 5 and 20 words all in lower case.
- category: text
- locale:
en-US
only - auxiliary constraints: format, length or size
properties:
- name: "text_sample"
type: "text"
constraints:
- type: "category"
name: "text"
Word Count
The number of word of generated text can be defined through either "size" constraint or "length" constraint. For a fixed length, "length" constraint should be used, on the other hand "size" is used for a ranged length.
- Fixed Length Text
- Ranged Length Text
properties:
- name: "text_sample"
type: "text"
constraints:
- type: "category"
name: "text"
- type: "length"
max: 5
properties:
- name: "text_sample"
type: "text"
constraints:
- type: "category"
name: "text"
- type: "size"
min: 5
max: 10
The word count does not include any prefixes and suffixes provided
Text Format
Extra format can be defined through "format" constraint. In a format spec, you can define three extra properties:
- prefixes: list of prefixes to be added to the generated text
- suffixes: list of suffixes to be added to the generated text
- style: style of the generated text, allowed values are:
- 1: all lower case, e.g. "hello world"
- 2: all upper case, e.g. "HELLO WORLD"
- 3: upper case for first character, lower case for others, e.g. "Hello world"
- 4: camel case for each word, e.g. "Hello World"
properties:
- name: "formatted_text"
type: "text"
constraints:
- type: "category"
name: "text"
- type: "format"
format: |
prefixes:
- "This is"
suffixes:
- "and that's it"
style: 3
The format spec is parsed as YAML string in a separate process, please make sure pipe (|) character is at the beginning of the format string
Credit Card Number Provider
This provider generates a random credit card number that satisfies the Luhn algorithm. By default, it generates a 16-digit credit card number for Visa, MasterCard, American Express, or Discover card types.
properties:
- name: "credit_card_sample"
type: "text"
constraints:
- type: "category"
name: "credit_card"
Credit Card Number Format
Extra format can be defined through the format
constraint. The format is defined as a list of credit card formats, each with the following properties:
- network: network of the credit card, allowed values are visa, mastercard, amex, discover or custom. When it's custom, the prefixes property should be provided.
- allLengths: boolean value, default is false which generates 16 digits number only, when it's true, it generates all lengths for that network, for visa, the card number length is either 16 digits or 19 digits
- prefixes: list of prefixes used for the credit card number, when specified, the network property is ignored. It is recommended to use with
custom
network type.
- Define Networks
- Multiple Card Number Length
- Create Custom Card
properties:
- name: "credit_card_sample"
type: "text"
constraints:
- type: "category"
name: "credit_card"
- type: "format"
format: |
- network: "visa"
- network: "mastercard"
properties:
- name: "credit_card_sample"
type: "text"
constraints:
- type: "category"
name: "credit_card"
- type: "format"
format: |
- network: "visa"
allLengths: true
properties:
- name: "credit_card_sample"
type: "text"
constraints:
- type: "category"
name: "credit_card"
- type: "format"
format: |
- network: "custom"
prefix:
- "3528"
- "3529"
- "3530"
The format spec is parsed as YAML string in a separate process, please make sure pipe (|) character is at the beginning of the format string