askrobots / dbbasic Public

Model-config web apps: describe the app in configuration instead of writing code. Built on Polars and DuckDB.

0 downloads

dbbasic/services/validate_email.py
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 Add DBBasic crate engine logo and update README 0d628db 1 year, 2 months ago History
validate_email.py · 1.8 KB · 66 lines
1
2#!/usr/bin/env python3
3"""
4AI-Generated Service: validate-email
5Description: Validate email addresses and check format compliance
6Generated: 2025-09-19T16:21:11.091812
7"""
8
9from typing import Dict, Any, Optional
10import json
11import asyncio
12from datetime import datetime
13
14# AI-Generated Implementation
15async def validate_email(data: Dict[str, Any]) -> Dict[str, Any]:
16 """
17 Validate email addresses and check format compliance
18
19 Inputs: email, strict_mode
20 Outputs: is_valid, error_message, suggestions
21 """
22
23 try:
24 # Extract inputs
25 email = data.get('email', '')
26 strict_mode = data.get('strict_mode', None)
27
28 # AI-Generated Business Logic
29# Perform validation
30 errors = []
31 warnings = []
32
33 # AI-generated validation rules
34 if 'email' in locals() and '@' not in str(email):
35 errors.append('Invalid email format')
36
37 if 'phone' in locals() and len(str(phone).replace('-', '')) < 10:
38 warnings.append('Phone number may be incomplete')
39
40 result = {
41 'valid': len(errors) == 0,
42 'errors': errors,
43 'warnings': warnings
44 }
45
46 # Return results
47 return {
48 "success": True,
49 "timestamp": datetime.now().isoformat(),
50 "data": result
51 }
52
53 except Exception as e:
54 return {
55 "success": False,
56 "error": str(e),
57 "timestamp": datetime.now().isoformat()
58 }
59
60# Synchronous wrapper for compatibility
61def validate_email_sync(data: Dict[str, Any]) -> Dict[str, Any]:
62 """Synchronous wrapper for the async function"""
63 return asyncio.run(validate_email(data))
64
65# Export the service
66__all__ = ['validate_email', 'validate_email_sync']