No project description provided
Project description
User Registration Validation System
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
-
Clone the repository:
git clone https://github.com/yourusername/typing_dataclasses.git cd typing_dataclasses
-
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) |
| Standard email format (RFC 5322) |
Custom Exceptions
InvalidNameError: Name contains invalid charactersInvalidAgeError: Age outside valid rangeInvalidEmailError: Malformed email address
Contributing
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/AmazingFeature) - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdccab72f6eb6cf07b42f52af483820bdefe5b84a7986a67769f3ca84586aee9
|
|
| MD5 |
75cf7efe9342d93205bf8df11fba5fc3
|
|
| BLAKE2b-256 |
8e9b889210b0d0c994841249fe9878cbb0a61fb2a53b74193c2e0dfd41dcecc2
|
File details
Details for the file typing_dataclasses-0.1.0-py3-none-any.whl.
File metadata
- Download URL: typing_dataclasses-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.13.3 Darwin/24.4.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87b8e2780b47271e3a731beb43de63cde25424a8dab6b27adad7bb6c964390b1
|
|
| MD5 |
4fd7a81b15d361b0c99359055fe0b106
|
|
| BLAKE2b-256 |
46e3820dc8d6ef315ca36369b7e5ff91d9045381047f539515001befa44f708c
|