(20250225) fmlllll
This commit is contained in:
@@ -48,6 +48,10 @@ from bson.objectid import ObjectId
|
|||||||
# To work with currencies:
|
# To work with currencies:
|
||||||
import pycountry
|
import pycountry
|
||||||
|
|
||||||
|
# For random strings:
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
|
||||||
|
|
||||||
# *****************************************************************************************************************
|
# *****************************************************************************************************************
|
||||||
# ***** ****
|
# ***** ****
|
||||||
@@ -199,7 +203,7 @@ class PGPaymentRequestData(BaseModel):
|
|||||||
examples = ["INR", "USD", "KES"]
|
examples = ["INR", "USD", "KES"]
|
||||||
)
|
)
|
||||||
|
|
||||||
description: str | None = Field(
|
description: str = Field(
|
||||||
description = "a short, human-readable description of the payment",
|
description = "a short, human-readable description of the payment",
|
||||||
frozen = True
|
frozen = True
|
||||||
)
|
)
|
||||||
@@ -240,6 +244,10 @@ class PGPaymentRequestData(BaseModel):
|
|||||||
if currency is None: raise ValueError("invalid currency code, please use iso 4217 standard")
|
if currency is None: raise ValueError("invalid currency code, please use iso 4217 standard")
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
@field_validator("description", mode = "before")
|
||||||
|
def ensure_description(cls, value):
|
||||||
|
if value is None: value = "rndm_" + "".join(random.choices(string.ascii_letters + string.digits, k = 20))
|
||||||
|
|
||||||
@field_validator("tags", mode = "after")
|
@field_validator("tags", mode = "after")
|
||||||
def null_to_empty_list(cls, value):
|
def null_to_empty_list(cls, value):
|
||||||
return [] if value is None else value
|
return [] if value is None else value
|
||||||
|
|||||||
Reference in New Issue
Block a user