Spaces:
Runtime error
Runtime error
| # schemas/request_schema.py | |
| from pydantic import BaseModel, Field, validator | |
| class PredictRequest(BaseModel): | |
| """ | |
| Schema untuk request prediksi fraud. | |
| Menggunakan Pydantic agar validasi otomatis. | |
| """ | |
| location: int = Field(..., description="ID lokasi transaksi") | |
| amount: float = Field(..., description="Jumlah nominal transaksi") | |
| def amount_must_be_positive(cls, v): | |
| if v <= 0: | |
| raise ValueError('amount harus > 0') | |
| return v | |
| def location_must_be_positive(cls, v): | |
| if v < 0: | |
| raise ValueError('location harus >= 0') | |
| return v | |