Inferensys

Prompt

Email and Phone Format Variant Generation Prompt Template

A practical prompt playbook for generating email addresses and phone numbers that span valid RFC formats, common typos, international variants, and deliberately invalid patterns for contact field validation testing.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job-to-be-done, the ideal user, required context, and when this prompt is the wrong tool.

This prompt is designed for QA engineers and developers who need to validate contact field normalization and input validation logic. The core job is to generate a comprehensive set of email addresses and phone numbers that span valid RFC formats, common user typos, international variants, and deliberately invalid patterns. Each generated variant must be labeled with its expected validation outcome, making it immediately useful for automated test suites that verify whether a system correctly accepts, rejects, or normalizes contact data.

Use this prompt when you are building or maintaining a test suite for user registration forms, profile update endpoints, CRM data ingestion pipelines, or any system that stores and processes contact information. It is particularly valuable before a release that touches validation rules, when onboarding a new international market that introduces unfamiliar phone formats, or when hardening a system against malformed input that could cause downstream processing errors. The prompt requires you to provide the target validation rules, accepted formats, and any locale-specific constraints so the generated variants are relevant to your system under test.

Do not use this prompt for generating production contact data, sending actual emails, or making real phone calls. It is not a data cleaning tool for existing databases, nor is it a substitute for a proper email verification service. If your goal is to test email deliverability or phone number reachability, you need a different workflow that involves actual sending infrastructure and bounce handling. For performance testing that requires millions of records, pair this prompt with the Large Volume Database Seeding Prompt Template rather than relying on a single generation run. Always review the generated variants before feeding them into automated test pipelines, especially when the prompt produces edge cases for international formats you may not fully understand—a quick human sanity check prevents false positives in your validation tests.

PRACTICAL GUARDRAILS

Use Case Fit

Where the email and phone format variant prompt works well and where it introduces risk. Use these cards to decide if this prompt fits your test data pipeline or if you need a different approach.

01

Good Fit: Contact Field Validation Testing

Use when: You need to verify that your application's email and phone validation logic correctly accepts RFC-compliant formats and rejects known invalid patterns. Guardrail: Map each generated variant to an expected validation outcome (accept/reject) before running tests, so you can detect regressions in validation rules.

02

Good Fit: Internationalization QA

Use when: Testing that your system handles international phone formats (E.164, national conventions) and email addresses with internationalized domains. Guardrail: Include locale-specific expected normalization results, not just format validity. A valid Japanese phone format may still fail if your system only expects North American patterns.

03

Bad Fit: Deliverability Testing

Avoid when: You need to verify that emails will actually reach inboxes or that phone numbers are reachable. This prompt generates format variants, not live addresses. Guardrail: Use a dedicated email verification service or SMS gateway test endpoint for deliverability. Never send test messages to generated addresses that might belong to real people.

04

Bad Fit: Production Contact Data Generation

Avoid when: You need to populate a production CRM, marketing list, or customer database with contact records. Generated addresses may collide with real inboxes or phone numbers. Guardrail: Restrict generated variants to test environments only. Use clearly marked test domains (example.com, test.com) and reserved phone ranges for any persistent test data.

05

Required Inputs: Validation Rule Set

Risk: Without a clear specification of what your application considers valid, the prompt may generate variants that don't align with your actual validation logic. Guardrail: Provide explicit validation rules (regex patterns, length constraints, allowed characters, required TLDs) as part of the prompt context. Test the prompt output against your actual validation functions, not assumptions.

06

Operational Risk: Format Drift Across Model Versions

Risk: Different model versions may interpret RFC specifications differently or generate inconsistent format labels across runs. Guardrail: Pin your model version in test configurations. Store generated variant sets as versioned test fixtures rather than regenerating on every test run. Run a diff check when updating fixtures to catch unexpected changes.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for generating labeled email and phone format variants to test contact field validation logic.

This prompt template produces a structured dataset of email addresses and phone numbers designed to exercise your application's contact field normalization and validation rules. Each generated variant is labeled with its expected validation outcome (valid, invalid, or ambiguous), the format category it belongs to, and a brief rationale. Use this template when you need to verify that your validation logic correctly handles RFC-compliant formats, common user typos, international numbering plans, and deliberately malformed inputs. Do not use this prompt for generating production contact data or for testing systems where the validation rules are unknown to you—the prompt assumes you understand your own acceptance criteria.

text
You are a test data generator for contact field validation. Your task is to produce a structured list of email addresses and phone numbers that exercise validation logic for normalization and format checking.

Generate variants for the following contact type: [CONTACT_TYPE]

Include variants from these categories: [VARIANT_CATEGORIES]

For each variant, provide:
- The raw input string
- The expected validation outcome: valid | invalid | ambiguous
- The format category label (e.g., RFC 5322 compliant, common typo, international E.164, local format, deliberately malformed)
- A one-sentence rationale explaining why this variant is interesting for testing

Apply these constraints:
- [CONSTRAINTS]

Output format: Return a JSON array of objects with keys: "input", "expected_outcome", "category", "rationale".

Example output structure:
[
  {
    "input": "user@example.com",
    "expected_outcome": "valid",
    "category": "RFC 5322 compliant",
    "rationale": "Standard email format that any validator should accept."
  }
]

Risk level for this generation: [RISK_LEVEL]

To adapt this template, replace each square-bracket placeholder with concrete values. Set [CONTACT_TYPE] to email, phone, or both. Define [VARIANT_CATEGORIES] as a comma-separated list drawn from categories such as RFC-compliant formats, common typos (missing @, double dots, transposed characters), international variants (country-specific prefixes, local formatting conventions), edge cases (maximum length, unusual TLDs, quoted local parts), and deliberately invalid patterns (null bytes, script injection attempts, empty strings). Use [CONSTRAINTS] to specify domain-specific rules like "exclude addresses from disposable domains" or "only generate NANP phone numbers." Set [RISK_LEVEL] to low, medium, or high to control whether the prompt should avoid generating patterns that could resemble real contact data. After generating variants, validate the output against your expected schema before feeding it into your test harness.

IMPLEMENTATION TABLE

Prompt Variables

Inputs required for the Email and Phone Format Variant Generation Prompt Template. Each placeholder must be populated before execution to control variant scope, validation rules, and output structure.

PlaceholderPurposeExampleValidation Notes

[CONTACT_TYPE]

Specifies whether to generate email variants, phone variants, or both

both

Must be one of: email, phone, both. Reject any other value before prompt assembly.

[VALIDATION_RULESET]

Defines the validation standard to apply (RFC, E.164, custom regex)

RFC 5322 for email; E.164 for phone

Must resolve to a known ruleset identifier. If custom, provide the regex or grammar inline.

[VARIANT_COUNT_PER_CATEGORY]

Controls how many variants to generate per format category (valid, typo, invalid)

5

Must be an integer between 1 and 50. Higher values increase token usage and may hit output length limits.

[INCLUDE_INTERNATIONAL_VARIANTS]

Whether to generate country-specific phone formats or internationalized email domains

Must be true or false. When true, ensure [COUNTRY_CODES] is also provided for phone variants.

[COUNTRY_CODES]

List of ISO 3166-1 alpha-2 country codes for international phone format generation

["US", "GB", "JP", "BR"]

Must be a valid JSON array of strings. Each element must be a 2-letter uppercase country code. Empty array allowed if [INCLUDE_INTERNATIONAL_VARIANTS] is false.

[OUTPUT_SCHEMA]

Expected structure for each generated variant record

{"variant": "string", "category": "valid|typo|invalid", "expected_result": "pass|fail", "rule_violated": "string|null"}

Must be a valid JSON Schema or example object. Validate parseability before prompt assembly. Required fields: variant, category, expected_result.

[DELIBERATE_TYPO_PATTERNS]

List of typo classes to include (transposition, missing char, extra char, wrong TLD)

["transposition", "missing_char", "wrong_tld"]

Must be a JSON array of strings from the allowed set: transposition, missing_char, extra_char, wrong_tld, double_at, unicode_confusable. Reject unknown values.

[EXCLUDE_PATTERNS]

Specific patterns or domains to exclude from generation to avoid accidental real addresses

["@example.com", "@test.com"]

Must be a JSON array of strings. Each entry is a substring match against generated variants. Post-generation filter must remove any variant containing an excluded pattern.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Email and Phone Format Variant Generation prompt into a test data pipeline with validation, retries, and downstream consumption.

This prompt is designed to be called programmatically as part of a test data synthesis pipeline, not as a one-off chat interaction. The typical integration pattern is a script or test harness that reads a configuration specifying the number of variants per category (valid RFC emails, common typos, international phone numbers, deliberately invalid patterns), calls the LLM with the prompt template, parses the structured output, and writes the labeled records into a test data store or CSV file for consumption by contact field validation tests. The prompt expects a [VARIANT_COUNT] and optional [LOCALE] parameter to control output volume and regional phone format preferences. Because the output must be machine-readable, the prompt template includes a strict [OUTPUT_SCHEMA] requiring a JSON array of objects with value, type (email/phone), format_category (e.g., rfc5322-valid, common-typo, e164-international, deliberately-invalid), and expected_validation_result (pass/fail) fields. This schema contract is what makes the prompt usable in automated pipelines—downstream test runners can filter by expected_validation_result to build positive and negative test suites without manual inspection.

Validation and retry logic should be built into the harness, not trusted to the prompt alone. After receiving the LLM response, validate that every record contains all required fields, that type is exactly email or phone, that expected_validation_result is exactly pass or fail, and that the total record count matches the requested [VARIANT_COUNT]. For email variants, run a secondary format check: records labeled expected_validation_result: pass should conform to a basic RFC 5322 pattern (the harness can use a library like email-validator in Python), while records labeled fail should deliberately violate it. For phone variants, verify that pass records match E.164 format when format_category indicates international format. If validation fails, implement a retry loop with a maximum of 2 additional attempts, appending the validation errors to the prompt as [PREVIOUS_ERRORS] so the model can correct specific malformed records. Log every validation failure and retry attempt with the record index and error details for debugging prompt drift over time.

Model choice and temperature matter for this use case. The prompt benefits from a model with strong instruction-following and format discipline—GPT-4o, Claude 3.5 Sonnet, or equivalent—because the output must be syntactically valid JSON with precise category labels. Set temperature to 0.2 or lower to reduce creative variation that could produce ambiguous format categories. If using a local or open-weight model, test extensively for JSON compliance and category label consistency before integrating into CI. For high-volume generation (thousands of variants), consider batching requests with a larger [VARIANT_COUNT] per call (50-100 records) to reduce API overhead, but monitor for output truncation at the model's maximum token limit. Do not use this prompt for generating actual contact data that will be sent to real email addresses or phone numbers—the harness should include a safety check that prevents generated values from being used outside the test environment. Wire the output into your test database seeder or parameterized test framework (pytest, JUnit, etc.) so that each variant becomes a test case with the expected_validation_result field driving the assertion. For teams with compliance requirements, log the prompt version, model, timestamp, and generated record count as audit evidence that test data was synthetically generated and never derived from production.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact fields, types, and validation rules your application should enforce on the model's response. Use this contract to build a post-processing validator before the output enters your test data pipeline.

Field or ElementType or FormatRequiredValidation Rule

variants

Array of objects

Array must contain at least one object. Reject if empty or missing.

variants[].value

String

Must be a non-empty string representing an email address or phone number. No leading/trailing whitespace.

variants[].type

Enum: 'email' | 'phone'

Must be exactly 'email' or 'phone'. Reject any other value.

variants[].category

Enum: 'valid_rfc' | 'common_typo' | 'international_variant' | 'deliberately_invalid'

Must match one of the four allowed categories. Reject unknown categories.

variants[].expected_validation_outcome

Enum: 'pass' | 'fail'

Must be exactly 'pass' or 'fail'. Reject if null or missing.

variants[].expected_error_code

String or null

If expected_validation_outcome is 'fail', this should be a non-empty string describing the expected rejection reason (e.g., 'INVALID_TLD', 'MISSING_COUNTRY_CODE'). If 'pass', must be null.

variants[].notes

String or null

Optional human-readable explanation of the variant's purpose. If present, must be a non-empty string.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when generating email and phone format variants and how to guard against it.

01

Model Defaults to Common Formats Only

What to watch: The model generates only standard user@domain.com emails and (555) 123-4567 phone numbers, missing international variants, RFC edge cases, and deliberate typos. This happens when the prompt lacks explicit diversity constraints. Guardrail: Add a required distribution clause in the prompt: 'Generate at least one example from each category: valid RFC, common typo, international variant, and deliberately invalid.' Verify category coverage in output validation before accepting the batch.

02

Invalid Formats Pass Validation Checks

What to watch: The model labels a malformed email or phone number as 'valid' or misclassifies the expected validation outcome. This corrupts your test oracle because the expected result is wrong. Guardrail: Post-process every generated variant through an actual validation library (e.g., Apache Commons Validator, libphonenumber) and flag mismatches between the model's label and the library's verdict. Discard or relabel mismatched records before seeding test suites.

03

International Number Formats Are Syntactically Invalid

What to watch: The model produces phone numbers with correct-looking country codes but incorrect digit lengths, misplaced trunk prefixes, or impossible area codes for the claimed region. Guardrail: Include a constraint requiring E.164 compliance for international numbers and validate every international variant against a reference library. Add a 'format_standard' field to each output record so testers can filter by compliance level.

04

Typos Are Too Subtle to Trigger Validation

What to watch: The model generates 'typos' that are still technically valid (e.g., user@domain..com becomes user@domain.com after normalization) or so extreme they don't represent real user errors. Guardrail: Define typo categories explicitly: missing @, double dots, unescaped special characters, Unicode lookalikes, and leading/trailing spaces. Require each typo variant to map to a specific validation rule it should violate.

05

Output Drifts Toward a Single Locale

What to watch: After the first few examples, the model collapses into generating variants for one country or region, ignoring the requested international spread. This is common with long generation runs. Guardrail: Shuffle locale requirements mid-prompt or split generation into multiple calls, each targeting a specific region. Validate locale diversity in the output batch by counting unique country codes or TLDs.

06

Deliberately Invalid Examples Leak Real Patterns

What to watch: The model generates 'invalid' emails that look like real addresses (e.g., test@example.com with a typo in the label) or phone numbers that could belong to real people. This creates privacy risk in test data. Guardrail: Constrain all generated values to use reserved domains (example.com, test.invalid) and reserved phone ranges (+1 555). Add a post-generation scan for patterns outside reserved ranges and quarantine any matches.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of generated email and phone format variants before integrating them into a test suite. Each criterion targets a specific failure mode common to contact field generation.

CriterionPass StandardFailure SignalTest Method

RFC Format Coverage

At least 80% of generated email variants match a known RFC 5321/5322 format category (valid, obsolete, or explicitly invalid per spec)

Output contains only common formats (e.g., user@domain.com) with no quoted strings, comments, IP literals, or domain literals

Parse each variant against an RFC 5322 regex. Count distinct format categories present in the output.

Expected Validation Outcome Accuracy

Every variant labeled as 'valid' passes a standard email/phone validator; every variant labeled 'invalid' fails

A variant labeled 'valid' is rejected by the validator, or a variant labeled 'invalid' is accepted

Run each variant through a reference validator library (e.g., Apache Commons Validator for email, libphonenumber for phone). Compare actual result to the label.

International Phone Format Diversity

Output includes at least 5 distinct country calling codes and examples of both E.164 and national formatting with spaces or hyphens

All phone variants use a single country code or only E.164 format without local formatting variants

Count unique country codes. Check for presence of both +[CC]NNNNNNNNNN and 0NNNN-NNN-NNNN style formats.

Deliberate Invalid Pattern Presence

At least 20% of variants are labeled as invalid and include specific pattern violations (e.g., double @, unicode homoglyphs, missing TLD, invalid country code)

All variants are valid, or invalid variants are only trivial typos without structural violations

Count invalid-labeled variants. Verify each contains a specific, identifiable violation rather than random character noise.

Common Typo and User Error Simulation

Output includes realistic user errors: missing @, comma instead of period, extra dots, leading/trailing spaces, and transposed characters

Typos are nonsensical (e.g., random character insertion) rather than patterns observed in real user input

Check for presence of at least 4 distinct error categories from a predefined typo taxonomy (missing-symbol, substitution, transposition, whitespace).

Variant Label Completeness

Every variant has exactly one label from the expected set: 'valid', 'invalid', 'typo', 'international', or 'edge-case'

Variants are missing labels, have multiple conflicting labels, or use labels not in the expected set

Parse labels from output. Assert each variant has exactly one label and that label is in the allowed set.

Output Schema Consistency

All variants conform to the specified output schema (e.g., JSON array of objects with 'value', 'label', and 'expected_result' fields)

Output is a plain text list, missing required fields, or has inconsistent field names across variants

Validate output against the JSON schema. Check for missing fields, extra fields, and type mismatches.

No Production Data Leakage

No generated email or phone number matches a known production record or contains real-looking personal identifiers

Scan output against a blocklist of known production domains and name patterns. Flag any variant that matches a real-world pattern.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a smaller variant count (e.g., 10-20). Remove the [OUTPUT_SCHEMA] constraint and accept free-text or CSV output. Focus on format coverage breadth over validation labeling accuracy.

Watch for

  • Variants that look plausible but don't actually match the described format category
  • Missing edge cases like quoted local parts or international prefixes
  • No distinction between "valid per RFC" and "valid per common application logic"
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.