or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pydantic@2.11.x
tile.json

tessl/pypi-pydantic

tessl install tessl/pypi-pydantic@2.11.0

Data validation using Python type hints

Agent Success

Agent success rate when using this tile

90%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.3x

Baseline

Agent success rate without this tile

69%

task.mdevals/scenario-5/

Event Registration System

Build a data validation system for processing event registrations that handles various data types including dates, times, numbers, and collections.

Requirements

Your system should validate event registration data with the following fields:

Registration Fields

  • event_id: A UUID that uniquely identifies the event
  • participant_name: A text string for the participant's name
  • email: The participant's email address
  • registration_date: The date when registration was submitted (date only, no time)
  • event_datetime: The full date and time when the event occurs
  • ticket_count: A positive integer representing number of tickets (must be at least 1)
  • total_cost: A decimal number representing the total cost in dollars
  • tags: A set of unique text labels associated with this registration
  • preferences: A dictionary mapping preference names (text) to boolean values
  • notes: Optional text field for additional notes

Input Handling

The system should accept registration data in dictionary format and automatically:

  • Convert string representations to appropriate types (e.g., "2024-03-15" to date object)
  • Validate that UUIDs are properly formatted
  • Ensure email addresses are valid
  • Verify dates and times are valid temporal values
  • Check that numbers meet specified constraints
  • Handle collections (sets and dictionaries) appropriately

Output

After validation, the system should be able to:

  • Convert validated data back to a dictionary format
  • Serialize to JSON format

Test Cases

  • The system validates a complete registration with all fields correctly typed @test
  • The system converts string date "2024-06-15" to a proper date object @test
  • The system converts string datetime "2024-06-15T14:30:00" to a proper datetime object @test
  • The system rejects ticket_count of 0 as it must be positive @test
  • The system converts string UUID "550e8400-e29b-41d4-a716-446655440000" to UUID object @test
  • The system validates a preferences dictionary with boolean values @test
  • The system handles a tags set ensuring uniqueness @test
  • The system correctly serializes validated data to JSON format @test

Implementation

@generates

API

class EventRegistration:
    """
    Validates and manages event registration data with automatic type conversion.

    Should handle all specified fields with appropriate validation and type coercion.
    """
    pass

Dependencies { .dependencies }

pydantic { .dependency }

Provides data validation and type conversion support.