Skip to main content

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 NameCategory NameDescription
NamenameA person name
AddressaddressAn address
EmailemailAn email
IdidId String
IP AddressipIP4 address
Text StringtextA line of formatted text
Credit Cardcredit_cardA 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.
warning

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 or ja-JP. The default is en-US.
  • qualifier: If firstname or lastname is not provided, it generates the full name.
Create Japanese full name
  properties:
- name: "full_name_sample"
type: "text"
constraints:
- type: "category"
name: "name"
locale: "ja-JP"

Address Provider

This provider generates random address

  • category: address
  • locale: An IETF BCP 47 language tag string, such as en-US or ja-JP. The default is en-US.
  • qualifier: It can be street, city, state, country or zip. Without qualifier value, full address is generated
Create full in Taiwan
  properties:
- name: "full_address_sample"
type: "text"
constraints:
- type: "category"
name: "address"
locale: "zh-TW"

Email Provider

This provider generates random email address.

  • category: email
Create email address
    properties:
- name: "email_sample"
type: "text"
constraints:
- type: "category"
name: "email"
note

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"
note

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
Create UUID
  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 ID with format ID-##########
  # 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-##########"

IP Address Provider

This provider generates random IP4 address

  • category: ip
  • auxiliary constraints: format
Create IP Address
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 with masks
### 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.###.###"
warning

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
Create random text string
    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.

Create text with 5 words
    properties:
- name: "text_sample"
type: "text"
constraints:
- type: "category"
name: "text"
- type: "length"
max: 5
note

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"
Create text with format
properties:
- name: "formatted_text"
type: "text"
constraints:
- type: "category"
name: "text"
- type: "format"
format: |
prefixes:
- "This is"
suffixes:
- "and that's it"
style: 3
warning

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.

Create credit card number
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.
Create Credit Card Number for Visa or MasterCard
properties:
- name: "credit_card_sample"
type: "text"
constraints:
- type: "category"
name: "credit_card"
- type: "format"
format: |
- network: "visa"
- network: "mastercard"
warning

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