Skip to main content

Misc/Util

This page defines the supported base number types available from the Mockd API.

Null

null - Always returns a value of null.

POST Body
{
"fields": {
"orders": "null"
}
}
Response
{ "orders": null }

UUID

uuidv4 - A random UUID value of type UUIDv4.

POST Body
{
"fields": {
"id": "uuidv4"
}
}
Response
{ "id": "fd9c9c68-81b3-4e51-b60d-b78d621303d2" }

Boolean

bool - A random true/false value.

bool-true - Always returns a value of true.

bool-false - Always returns a value of false;

POST Body
{
"fields": {
"isActive": "bool"
}
}
Response
{ "isActive": true }

Constant

const - The const type is a special type that functions as a string pass-thru. When using the const type you must also specify a "value" field. The value provided will be returned in the response unaltered.

POST Body
{
"fields": {
"memberStatus": "const-[REGULAR]"
}
}
Response
{ "memberStatus": "REGULAR" }

Mask

mask - The masked type can be used to specify a format that a randomly generated numeric value should conform to. Be sure to specify the mask to be used in the "value" field.

POST Body
{
"fields": {
"accountNum": "mask-[TT-####]"
}
}
Response
{ "accountNum": "TT-2245" }

Array

array - Create an array based on the other types currently available. Provide the type desired in square brackets and then the desired array size inside of parenthesis. Note: The max array size currently supported is 100.

POST Body
{
"fields": {
"feedPosts": "array-[uuidv4(4)]"
}
}
Response
{ 
"feedPosts": [
"2ea18a82-2b24-4357-a73b-876f7b3db2ec",
"00ebbe9a-d31f-4cf4-85ba-3714b85f42e0",
"b788ade0-df62-4fd4-b939-8b5e2c6ddaa9",
"0b38d13c-eb87-4609-9800-791630720ec2"
]
}
Type Support

The mask type is not currently supported by the array type. This will be implemented in a future update.

Object

object - The object type allows you to define a custom structure in the types object of your request and reference it in your fields.

POST Body
{
"types": {
"User": {
"id": "uuidv4",
"name": "male-full-name",
"email": "email"
}
},
"fields": {
"admin": "object-[User]"
}
}
Response
{
"admin": {
"id": "fd9c9c68-81b3-4e51-b60d-b78d621303d2",
"name": "John Doe",
"email": "john.doe@example.com"
}
}

Object Array

object-array - Create an array of custom objects defined in your types object. Reference your custom type using object-array-[typeName(size)].

POST Body
{
"types": {
"Product": {
"sku": "mask-[AAA-####]",
"price": "money"
}
},
"fields": {
"inventory": "object-array-[Product(3)]"
}
}
Response
{
"inventory": [
{ "sku": "AAA-1234", "price": "$10.00" },
{ "sku": "AAA-5678", "price": "$20.00" },
{ "sku": "AAA-9012", "price": "$30.00" }
]
}

Enum

enum - Select a random item from a provided comma-separated list of strings. The list should be provided within square brackets.

POST Body
{
"fields": {
"myChoice": "enum-[red,green,blue]"
}
}
Response
{ "myChoice": "green" }

Color

color-hex - Returns a random hexadecimal color string (e.g., #FF00AB).

POST Body
{
"fields": {
"themeColor": "color-hex"
}
}
Response
{ "themeColor": "#A1C2E3" }

NATO Phonetic Alphabet

nato - Transforms a string into its phonetic equivalent using the NATO phonetic alphabet.

POST Body
{
"fields": {
"natoText": "nato-[nato]"
}
}
POST Response
{
"natoText": "NOVEMBER ALPHA TANGO OSCAR"
}

nato-reverse - Transforms a string into its phonetic equivalent using the NATO phonetic alphabet in reverse order.

POST Body
{
"fields": {
"natoText": "nato-reverse-[NOVEMBER ALPHA TANGO OSCAR]"
}
}
POST Response
{
"natoText": "NATO"
}

Note: Nato reverse will omit the next character in the provided string if the next character is a space. If the next character is not a space, it will be maintained. Use a double space if you wish to maintain original spacing directly following a NATO word from the phonetic alphabet.