Advanced Data Generation Customization
Drafta allows users to customize generated data by specifying formats, value ranges, and example patterns. This enables the creation of more precise test data that aligns with real-world expectations.
Syntax Format
Customization follows this pattern:
field_name: data_type @data_format min_value-max_value (example_format)
Components:
field_name
: The name of the field.data_type
: One ofstring
,number
,boolean
, orenum
.data_format
: An optional format specifier (e.g.,uuid
,email
,date
).min_value-max_value
: Defines the valid range (only fornumber
).example_format
: Provides an example structure for guidance.
Basic Field Customization
This example defines a user schema with customized field types, including UUIDs, full names, numeric ranges, and boolean probabilities.
User:
id: string @uuid
name: string @full_name
age: number 18-65
is_active: boolean
Generated Output:
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Alice Johnson",
"age": 34,
"is_active": true
}
Customizing Strings and Numbers
This example customizes product data by specifying formats such as UUIDs, product names, price ranges with a currency format, and stock limits.
Product:
id: string @uuid
name: string @product_name
price: number 5.00-999.99 (currency)
stock: number 0-1000
available: boolean
Generated Output:
{
"id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"name": "Wireless Mouse",
"price": 49.99,
"stock": 120,
"available": true
}
String Formats
This example focuses on string data formats, including sentences, paragraphs, full names, and formatted dates.
Document:
title: string @sentence
description: string @paragraph
author: string @full_name
published_date: string @date (YYYY-MM-DD)
Generated Output:
{
"title": "The Future of AI",
"description": "Artificial Intelligence is transforming industries across the globe, making processes more efficient and improving decision-making capabilities.",
"author": "Jane Doe",
"published_date": "2025-02-20"
}
String Abbreviations
This example defines full names and their abbreviations with a fixed length constraint.
State:
name: string @full_name
abbreviation: string @state_abbr
country: string full_name
Generated Output:
{
"name": "California",
"abbreviation": "CA",
"country": "United States"
}
Referencing Objects with Customization
This example demonstrates referencing other objects while applying constraints on numeric values and date formatting.
Invoice:
invoice_id: string @uuid
customer: $User
items: [$Product]
total: number 20.00-10000.00 (currency)
issued_date: string @date (YYYY-MM-DD)
Generated Output:
{
"invoice_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"customer": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Alice Johnson",
"age": 34,
"is_active": true
},
"items": [
{
"id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"name": "Wireless Mouse",
"price": 49.99,
"stock": 120,
"available": true
}
],
"total": 299.99,
"issued_date": "2025-02-20"
}
These examples illustrate how to fine-tune data generation in Drafta, ensuring realistic and domain-specific test datasets.