import re import typing from math import isfinite from apistar import formats from apistar.compat import dict_type from apistar.exceptions import ValidationError NO_DEFAULT = object() FORMATS = { 'date': formats.DateFormat(), 'time': formats.TimeFormat(), 'datetime': formats.DateTimeFormat() } class Validator(): errors = {} _creation_counter = 0 def __init__(self, title='', description='', default=NO_DEFAULT, definitions=None, def_name=None): definitions = {} if (definitions is None) else dict_type(definitions) assert isinstance(title, str) assert isinstance(description, str) assert isinstance(definitions, dict) assert all(isinstance(k, str) for k in definitions.keys()) assert all(isinstance(v, Validator) for v in definitions.values()) self.title = title
import re import typing from math import isfinite from apistar import formats from apistar.compat import dict_type from apistar.exceptions import ValidationError NO_DEFAULT = object() FORMATS = { "date": formats.DateFormat(), "time": formats.TimeFormat(), "datetime": formats.DateTimeFormat(), } class ErrorMessage(str): def __new__(cls, message, code): instance = str.__new__(cls, message) instance.code = code return instance class Validator: errors = {} _creation_counter = 0 def __init__( self, title="",