Skip to content

Variablilize value format

format.variables

Setting the value format with some specific settings which be configured as variables.

format.variables[*].name

The naming of the format variable setting. For outside setting, it would use the value of this property to identify which format variable setting it should use to generate the random value. So in a format variable array, this value must be unique.

format.variables[*].value_format

The format type how it should generate the random value.

The following format types are provided by PyFake-API-Server:

Strategy name Purpose Example result
str Randomly generate value as string type value hjwgowjf
int Randomly generate value as integer type value 123456
big_decimal Randomly generate value as decimal type value 123456678.123456
bool Randomly generate value as boolean type value true
date Randomly generate string type value as date format 2025-01-22
date-time Randomly generate string type value as date and time format 2025-01-25T16:19:08
enum Randomly generate value from an array val1 in [val1, val2, val3]
email Randomly generate string type value as email format1 twfsdg@gmail
uuid Randomly generate string type value as UUID format d2ecff78-d899-11ef-891f-be31ef195676
uri Randomly generate string type value as URI2 format https://www.fkjgsj.com
url Randomly generate string type value as URL format https://www.fkjgsj.com
ipv4 Randomly generate string type value as IPv4 format 172.30.15.101
ipv6 Randomly generate string type value as IPv6 format 2001:db8:2de::e13

format.variables[*].digit

Set the digit setting of the value.

This property is the totally same function with format.digit.

format.variables[*].size

Set the value size of the value.

This property is the totally same function with format.size.

format.variables[*].static_value

Set the specific value as being fixed.

This property is the totally same function with format.static_value.

New in version 0.4.2

format.variables[*].unique_element

Set the value as element of array should be unique or not.

This property is the totally same function with format.unique_element.

New in version 0.4.2

format.variables[*].enum

If the value must be one of multiple values, it could set the multiple values as an array at this property. The value would be randomly generated from the array.

This property is the totally same function with format.enums.


  1. Currently, it only supports randomly generate email as gmail, outlook or yahoo

  2. About the URI (uniform resource identifiers) specification, it haa been defined twice in RFC: RFC 2396 and RFC 3986