This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import boto3 | |
from email.mime.application import MIMEApplication | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
from bs4 import BeautifulSoup | |
from html import unescape | |
from service.response import Response | |
from email.utils import formataddr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def validate(model, data): | |
if not isinstance(model, dict): | |
model = model.__dict__["__annotations__"] | |
for k, v in model.items(): | |
assert k in data, f"Key {k} is not available in data provided" | |
if 'typing.' in str(model[k]): | |
types = model[k].__args__ | |
assert any(map(lambda x: isinstance(data[k], x), types)), f"Value of key {k}: {data[k]} is not of type(s) {types}" | |
elif issubclass(v, BaseModel): | |
validate(model[k], data[k]) |