Skip to main content

No project description provided

Project description

User Registration Validation System

Python License Code Style

A robust Python implementation for validating and registering user data with strict type checking and custom validation rules.

Features

  • Data Validation:
    • Name: Letters and spaces only
    • Age: 0-120 range check
    • Email: Comprehensive regex validation
  • Error Handling:
    • Custom exceptions for each validation failure
    • Clear error messages
  • Modern Python:
    • Type hints throughout
    • Dataclasses for clean data modeling
    • Regex pattern constants

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/typing_dataclasses.git
    cd typing_dataclasses
    
  2. Install dependencies (none beyond Python standard library):

    pip install -r requirements.txt  # (Optional: for future dependencies)
    

Usage

from main import Validate

test_data = {
    "name": "John Doe",
    "age": 30,
    "email": "john@example.com"
}

try:
    Validate(test_data)
except (InvalidNameError, InvalidAgeError, InvalidEmailError) as e:
    print(f"Validation failed: {e}")

Expected Output

Successful Validation:

Registered: User(name='John Doe', age=30, email='john@example.com', is_active=True)

Failed Validations:

Error caught: Invalid name: John42
Error caught: Invalid age: 150
Error caught: Invalid email: invalid-email

Class Structure

classDiagram
    class User{
        +name: str
        +age: int
        +email: str
        +is_active: bool
    }
    
    class Validate{
        +EMAIL_REGEX: str
        +NAME_REGEX: str
        +_validate_input()
        +_validate_user()
        +_register_user()
    }
    
    User <-- Validate : Creates

Validation Rules

Field Rules
Name Only letters and spaces (^[a-zA-Z\s]+$)
Age Between 0 and 120 (inclusive)
Email Standard email format (RFC 5322)

Custom Exceptions

  • InvalidNameError: Name contains invalid characters
  • InvalidAgeError: Age outside valid range
  • InvalidEmailError: Malformed email address

Contributing

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

TODO

  • Add logging configuration
  • Implement unit tests
  • Add database integration
  • Create REST API wrapper

Made with ❤️ by Nemkov

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typing_dataclasses-0.1.0.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

typing_dataclasses-0.1.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file typing_dataclasses-0.1.0.tar.gz.

File metadata

  • Download URL: typing_dataclasses-0.1.0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.13.3 Darwin/24.4.0

File hashes

Hashes for typing_dataclasses-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fdccab72f6eb6cf07b42f52af483820bdefe5b84a7986a67769f3ca84586aee9
MD5 75cf7efe9342d93205bf8df11fba5fc3
BLAKE2b-256 8e9b889210b0d0c994841249fe9878cbb0a61fb2a53b74193c2e0dfd41dcecc2

See more details on using hashes here.

File details

Details for the file typing_dataclasses-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for typing_dataclasses-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87b8e2780b47271e3a731beb43de63cde25424a8dab6b27adad7bb6c964390b1
MD5 4fd7a81b15d361b0c99359055fe0b106
BLAKE2b-256 46e3820dc8d6ef315ca36369b7e5ff91d9045381047f539515001befa44f708c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page