Spaces:
Sleeping
Sleeping
Create validation.py
Browse files- validation.py +78 -0
validation.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pydantic import ValidationError
|
| 2 |
+
from app import TransactionData # Reuse model from app.py
|
| 3 |
+
import json
|
| 4 |
+
|
| 5 |
+
# Example JSON input (update as needed)
|
| 6 |
+
sample_input = {
|
| 7 |
+
"Transaction_Id": "T123456789",
|
| 8 |
+
"Hit_Seq": 1,
|
| 9 |
+
"Hit_Id_List": "HIT001",
|
| 10 |
+
"Origin": "USA",
|
| 11 |
+
"Designation": "Manager",
|
| 12 |
+
"Keywords": "Payment",
|
| 13 |
+
"Name": "John Doe",
|
| 14 |
+
"SWIFT_Tag": "TAG001",
|
| 15 |
+
"Currency": "USD",
|
| 16 |
+
"Entity": "CompanyX",
|
| 17 |
+
"Message": "This is a test message",
|
| 18 |
+
"City": "New York",
|
| 19 |
+
"Country": "USA",
|
| 20 |
+
"State": "NY",
|
| 21 |
+
"Hit_Type": "Name Match",
|
| 22 |
+
"Record_Matching_String": "Matching String Example",
|
| 23 |
+
"WatchList_Match_String": "Watchlist Match Example",
|
| 24 |
+
"Payment_Sender_Name": "Alice",
|
| 25 |
+
"Payment_Reciever_Name": "Bob",
|
| 26 |
+
"Swift_Message_Type": "MT103",
|
| 27 |
+
"Text_Sanction_Data": "Sanction text here",
|
| 28 |
+
"Matched_Sanctioned_Entity": "Entity XYZ",
|
| 29 |
+
"Is_Match": 1,
|
| 30 |
+
"Red_Flag_Reason": "High Risk",
|
| 31 |
+
"Risk_Level": "High",
|
| 32 |
+
"Risk_Score": 85.0,
|
| 33 |
+
"Risk_Score_Description": "High Risk Score",
|
| 34 |
+
"CDD_Level": "Enhanced",
|
| 35 |
+
"PEP_Status": "No",
|
| 36 |
+
"Value_Date": "2023-10-01",
|
| 37 |
+
"Last_Review_Date": "2023-11-01",
|
| 38 |
+
"Next_Review_Date": "2024-11-01",
|
| 39 |
+
"Sanction_Description": "Some sanctions",
|
| 40 |
+
"Checker_Notes": "Verified manually",
|
| 41 |
+
"Sanction_Context": "Transaction under review",
|
| 42 |
+
"Maker_Action": "Escalated",
|
| 43 |
+
"Customer_ID": 1001,
|
| 44 |
+
"Customer_Type": "Corporate",
|
| 45 |
+
"Industry": "Finance",
|
| 46 |
+
"Transaction_Date_Time": "2023-10-01T12:00:00",
|
| 47 |
+
"Transaction_Type": "Transfer",
|
| 48 |
+
"Transaction_Channel": "Online",
|
| 49 |
+
"Originating_Bank": "Bank A",
|
| 50 |
+
"Beneficiary_Bank": "Bank B",
|
| 51 |
+
"Geographic_Origin": "USA",
|
| 52 |
+
"Geographic_Destination": "UK",
|
| 53 |
+
"Match_Score": 0.95,
|
| 54 |
+
"Match_Type": "Fuzzy",
|
| 55 |
+
"Sanctions_List_Version": "v2023.10",
|
| 56 |
+
"Screening_Date_Time": "2023-10-01T10:00:00",
|
| 57 |
+
"Risk_Category": "Fraud",
|
| 58 |
+
"Risk_Drivers": "Transaction Volume",
|
| 59 |
+
"Alert_Status": "Open",
|
| 60 |
+
"Investigation_Outcome": "Pending",
|
| 61 |
+
"Case_Owner_Analyst": "Analyst1",
|
| 62 |
+
"Escalation_Level": "Level 2",
|
| 63 |
+
"Escalation_Date": "2023-10-02",
|
| 64 |
+
"Regulatory_Reporting_Flags": True,
|
| 65 |
+
"Audit_Trail_Timestamp": "2023-10-01T10:15:00",
|
| 66 |
+
"Source_Of_Funds": "Internal",
|
| 67 |
+
"Purpose_Of_Transaction": "Loan Repayment",
|
| 68 |
+
"Beneficial_Owner": "OwnerX",
|
| 69 |
+
"Sanctions_Exposure_History": False
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
if __name__ == "__main__":
|
| 73 |
+
try:
|
| 74 |
+
validated = TransactionData(**sample_input)
|
| 75 |
+
print(" Input is valid.")
|
| 76 |
+
except ValidationError as e:
|
| 77 |
+
print(" Validation failed:")
|
| 78 |
+
print(e.json())
|