fix: add validation to require 'to' field for TRANSFER transactions
Some checks failed
Blockchain Synchronization Verification / sync-verification (push) Failing after 10s
Integration Tests / test-service-integration (push) Has been cancelled
P2P Network Verification / p2p-verification (push) Has been cancelled
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 8s
Python Tests / test-python (push) Has been cancelled
Security Scanning / security-scan (push) Has started running
Some checks failed
Blockchain Synchronization Verification / sync-verification (push) Failing after 10s
Integration Tests / test-service-integration (push) Has been cancelled
P2P Network Verification / p2p-verification (push) Has been cancelled
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 8s
Python Tests / test-python (push) Has been cancelled
Security Scanning / security-scan (push) Has started running
This commit is contained in:
@@ -220,12 +220,11 @@ class TransactionRequest(BaseModel):
|
||||
if normalized not in valid_types:
|
||||
raise ValueError(f"unsupported transaction type: {normalized}. Valid types: {valid_types}")
|
||||
self.type = normalized
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_transfer_fields(self) -> "TransactionRequest": # type: ignore[override]
|
||||
|
||||
# Require 'to' field for TRANSFER transactions
|
||||
if self.type == "TRANSFER" and not self.to:
|
||||
raise ValueError("transaction.to is required for TRANSFER transactions")
|
||||
raise ValueError("'to' field is required for TRANSFER transactions")
|
||||
|
||||
return self
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user