Spaces:
Sleeping
Sleeping
| """ | |
| Activation Requirements Examples - Smart Validation | |
| Examples showing how to define activation requirements with minimal input. | |
| System automatically provides validation rules, placeholders, and help text. | |
| """ | |
| # Example 1: FTTH Installation (Minimal Input) | |
| ftth_minimal = { | |
| "title": "Nairobi FTTH Rollout 2025", | |
| "project_type": "installation", | |
| "service_type": "ftth", | |
| "activation_requirements": [ | |
| { | |
| "field": "customer_phone", | |
| "label": "Customer Phone Number", | |
| "type": "phone", | |
| "required": True | |
| }, | |
| { | |
| "field": "customer_email", | |
| "label": "Customer Email", | |
| "type": "email", | |
| "required": False | |
| }, | |
| { | |
| "field": "ont_serial", | |
| "label": "ONT Serial Number", | |
| "type": "serial_number", | |
| "required": True | |
| }, | |
| { | |
| "field": "ont_mac", | |
| "label": "ONT MAC Address", | |
| "type": "mac_address", | |
| "required": True | |
| }, | |
| { | |
| "field": "router_serial", | |
| "label": "Router Serial Number", | |
| "type": "serial_number", | |
| "required": False | |
| }, | |
| { | |
| "field": "static_ip", | |
| "label": "Static IP Address", | |
| "type": "ip_address", | |
| "required": False | |
| }, | |
| { | |
| "field": "speed_test_download", | |
| "label": "Download Speed (Mbps)", | |
| "type": "number", | |
| "required": True | |
| }, | |
| { | |
| "field": "speed_test_upload", | |
| "label": "Upload Speed (Mbps)", | |
| "type": "number", | |
| "required": True | |
| }, | |
| { | |
| "field": "customer_portal_url", | |
| "label": "Customer Portal URL", | |
| "type": "url", | |
| "required": False | |
| } | |
| ] | |
| } | |
| # Example 2: FTTH with Custom Validation (Override Defaults) | |
| ftth_custom = { | |
| "title": "Huawei FTTH Project", | |
| "project_type": "installation", | |
| "service_type": "ftth", | |
| "activation_requirements": [ | |
| { | |
| "field": "customer_phone", | |
| "label": "Customer Phone Number", | |
| "type": "phone", | |
| "required": True, | |
| "pattern": r"^\+254[0-9]{9}$", # Kenya-specific format | |
| "placeholder": "+254712345678", | |
| "help_text": "Enter Kenyan phone number starting with +254" | |
| }, | |
| { | |
| "field": "ont_serial", | |
| "label": "ONT Serial Number", | |
| "type": "serial_number", | |
| "required": True, | |
| "pattern": r"^HW[0-9]{8}$", # Huawei-specific format | |
| "min_length": 10, | |
| "max_length": 10, | |
| "placeholder": "HW12345678", | |
| "help_text": "Huawei ONT format: HW followed by 8 digits" | |
| }, | |
| { | |
| "field": "ont_mac", | |
| "label": "ONT MAC Address", | |
| "type": "mac_address", | |
| "required": True | |
| # Uses smart defaults: pattern, min/max length, placeholder, help_text | |
| }, | |
| { | |
| "field": "speed_test_download", | |
| "label": "Download Speed (Mbps)", | |
| "type": "number", | |
| "required": True, | |
| "help_text": "Minimum 50 Mbps required for 100 Mbps package" | |
| } | |
| ] | |
| } | |
| # Example 3: Fixed Wireless Installation | |
| fixed_wireless = { | |
| "title": "Rural Fixed Wireless Project", | |
| "project_type": "installation", | |
| "service_type": "fixed_wireless", | |
| "activation_requirements": [ | |
| { | |
| "field": "customer_phone", | |
| "label": "Customer Phone Number", | |
| "type": "phone", | |
| "required": True | |
| }, | |
| { | |
| "field": "cpe_serial", | |
| "label": "CPE Serial Number", | |
| "type": "serial_number", | |
| "required": True | |
| }, | |
| { | |
| "field": "cpe_mac", | |
| "label": "CPE MAC Address", | |
| "type": "mac_address", | |
| "required": True | |
| }, | |
| { | |
| "field": "signal_strength", | |
| "label": "Signal Strength (dBm)", | |
| "type": "number", | |
| "required": True, | |
| "help_text": "Signal strength in dBm (e.g., -65)" | |
| }, | |
| { | |
| "field": "tower_name", | |
| "label": "Tower/Base Station Name", | |
| "type": "text", | |
| "required": True, | |
| "max_length": 100 | |
| }, | |
| { | |
| "field": "installation_height", | |
| "label": "Installation Height (meters)", | |
| "type": "number", | |
| "required": False | |
| } | |
| ] | |
| } | |
| # Example 4: Support Ticket (Equipment Replacement) | |
| equipment_replacement = { | |
| "title": "ONT Replacement Support", | |
| "project_type": "support", | |
| "service_type": "ftth", | |
| "activation_requirements": [ | |
| { | |
| "field": "customer_phone", | |
| "label": "Customer Phone Number", | |
| "type": "phone", | |
| "required": True | |
| }, | |
| { | |
| "field": "old_ont_serial", | |
| "label": "Old ONT Serial (Removed)", | |
| "type": "serial_number", | |
| "required": True | |
| }, | |
| { | |
| "field": "new_ont_serial", | |
| "label": "New ONT Serial (Installed)", | |
| "type": "serial_number", | |
| "required": True | |
| }, | |
| { | |
| "field": "new_ont_mac", | |
| "label": "New ONT MAC Address", | |
| "type": "mac_address", | |
| "required": True | |
| }, | |
| { | |
| "field": "issue_description", | |
| "label": "Issue Description", | |
| "type": "text", | |
| "required": True, | |
| "max_length": 500, | |
| "help_text": "Describe the issue that required replacement" | |
| }, | |
| { | |
| "field": "issue_resolved", | |
| "label": "Issue Resolved?", | |
| "type": "boolean", | |
| "required": True | |
| } | |
| ] | |
| } | |
| # Example 5: Maintenance Ticket | |
| maintenance_ticket = { | |
| "title": "Network Maintenance", | |
| "project_type": "maintenance", | |
| "activation_requirements": [ | |
| { | |
| "field": "maintenance_type", | |
| "label": "Maintenance Type", | |
| "type": "select", | |
| "required": True, | |
| "options": ["Preventive", "Corrective", "Emergency", "Upgrade"] | |
| }, | |
| { | |
| "field": "affected_equipment", | |
| "label": "Affected Equipment", | |
| "type": "text", | |
| "required": True, | |
| "max_length": 200 | |
| }, | |
| { | |
| "field": "downtime_start", | |
| "label": "Downtime Start", | |
| "type": "date", | |
| "required": False | |
| }, | |
| { | |
| "field": "downtime_end", | |
| "label": "Downtime End", | |
| "type": "date", | |
| "required": False | |
| }, | |
| { | |
| "field": "work_performed", | |
| "label": "Work Performed", | |
| "type": "text", | |
| "required": True, | |
| "max_length": 1000 | |
| } | |
| ] | |
| } | |
| # Example 6: What Frontend Receives (Auto-Enhanced) | |
| # When frontend calls GET /api/v1/tickets/{id}/checklist | |
| frontend_receives = { | |
| "field_items": [ | |
| { | |
| "id": "field_customer_phone", | |
| "type": "field", | |
| "field_name": "customer_phone", | |
| "label": "Customer Phone Number", | |
| "data_type": "phone", | |
| "required": True, | |
| "placeholder": "+254XXXXXXXXX", # Auto-generated | |
| "help_text": "Enter phone number with country code", # Auto-generated | |
| "validation": { | |
| "min_length": 10, # Auto-set | |
| "max_length": 15, # Auto-set | |
| "pattern": r"^\+?[0-9]{10,15}$" # Auto-set | |
| }, | |
| "value": None, | |
| "status": "pending" | |
| }, | |
| { | |
| "id": "field_ont_serial", | |
| "type": "field", | |
| "field_name": "ont_serial", | |
| "label": "ONT Serial Number", | |
| "data_type": "serial_number", | |
| "required": True, | |
| "placeholder": "ABC123XYZ", # Auto-generated | |
| "help_text": "Enter equipment serial number", # Auto-generated | |
| "validation": { | |
| "min_length": 6, # Auto-set | |
| "max_length": 30, # Auto-set | |
| "pattern": r"^[A-Z0-9\-]+$" # Auto-set | |
| }, | |
| "value": None, | |
| "status": "pending" | |
| }, | |
| { | |
| "id": "field_ont_mac", | |
| "type": "field", | |
| "field_name": "ont_mac", | |
| "label": "ONT MAC Address", | |
| "data_type": "mac_address", | |
| "required": True, | |
| "placeholder": "AA:BB:CC:DD:EE:FF", # Auto-generated | |
| "help_text": "Enter MAC address (format: AA:BB:CC:DD:EE:FF)", # Auto-generated | |
| "validation": { | |
| "min_length": 17, # Auto-set | |
| "max_length": 17, # Auto-set | |
| "pattern": r"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$" # Auto-set | |
| }, | |
| "value": None, | |
| "status": "pending" | |
| } | |
| ] | |
| } | |
| # Example 7: Validation Errors (Type-Specific Messages) | |
| validation_errors = { | |
| "message": "Completion data validation failed", | |
| "errors": [ | |
| { | |
| "field_name": "customer_phone", | |
| "error_message": "Customer Phone Number must be at least 10 characters" | |
| }, | |
| { | |
| "field_name": "ont_mac", | |
| "error_message": "ONT MAC Address: Enter MAC address (format: AA:BB:CC:DD:EE:FF)" | |
| }, | |
| { | |
| "field_name": "speed_test_download", | |
| "error_message": "Download Speed (Mbps) must be a valid number" | |
| }, | |
| { | |
| "field_name": "customer_email", | |
| "error_message": "Customer Email: Enter valid email address" | |
| } | |
| ] | |
| } | |