first commit
This commit is contained in:
23
api_validations/core_validations.py
Normal file
23
api_validations/core_validations.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
def rewrite_input_data(data):
|
||||
|
||||
return {
|
||||
item[0]: item[1]
|
||||
for item in data.items()
|
||||
if not item[1] == "" and item[1] is not None
|
||||
}
|
||||
|
||||
|
||||
class BaseModelRegular(BaseModel):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**rewrite_input_data(kwargs))
|
||||
|
||||
def excluded_dump(self):
|
||||
return self.model_dump(exclude_unset=True, exclude_none=True)
|
||||
|
||||
def dump(self):
|
||||
return self.model_dump()
|
||||
|
||||
Reference in New Issue
Block a user