Make failing during validation or conversion configurable
This commit is contained in:
parent
74c46f2647
commit
7770a3844c
|
@ -4,6 +4,9 @@ from pydantic import ValidationError
|
|||
from core.lib import schemas
|
||||
from core.util import logs
|
||||
|
||||
STRICT_VALIDATION = False
|
||||
STRICT_CONVERSTION = False
|
||||
|
||||
|
||||
class BaseExchange(object):
|
||||
def __init__(self, account):
|
||||
|
@ -34,7 +37,8 @@ class BaseExchange(object):
|
|||
else:
|
||||
# Let us know so we can implement it, but don't do anything with it
|
||||
self.log.error(f"No schema for message: {msg_type} - {response}")
|
||||
# raise Exception(f"No schema for {msg_type} in schema mapping")
|
||||
if STRICT_CONVERSION:
|
||||
raise Exception(f"No schema for {msg_type} in schema mapping")
|
||||
return response
|
||||
|
||||
# Use glom to convert the response to the schema
|
||||
|
@ -52,7 +56,8 @@ class BaseExchange(object):
|
|||
if method not in self.schema:
|
||||
self.log.error(f"Method cannot be validated: {method}")
|
||||
self.log.debug(f"Response: {response}")
|
||||
# return (False, f"Method cannot be validated: {method}")
|
||||
if STRICT_VALIDATION:
|
||||
return (False, f"Method cannot be validated: {method}")
|
||||
return (True, response)
|
||||
# Return a dict of the validated response
|
||||
response_valid = self.schema[method](**response).dict()
|
||||
|
|
Loading…
Reference in New Issue