def validate(self, data: object) -> object: from datetime import datetime try: cleaned_data = datetime.strptime(data, '%Y-%m-%d').date() return cleaned_data except (ValueError, TypeError): raise SchemaError(self.message)
def validate( self, data: object, watch_for_exceptions: Exception = (ValueError, TypeError) ) -> object: try: return self.pipe(data) except watch_for_exceptions as e: message = str(e) raise SchemaError(self.message or message)
def validate(self, data: object) -> object: messages = [] for condition in self.conditions: try: return condition.validate(data) except SchemaError as err: messages.append(err.error) message = self.message.format(messages=", ".join(messages)) raise SchemaError(message)
def validate(self, data: object) -> object: if not self._check(data): raise SchemaError(self.message.format(maxValue=self.maxValue)) return data
def validate(self, data: object) -> object: if not self._check(data): raise SchemaError(self.message) return data
def validate(self, data: object) -> object: if not self.predicate(data): raise SchemaError(self.get_message(data)) return data