def validate(self, schema=None): """ Validate that we have a valid object. On error, this will either raise a `ValueError` or a `validictory.ValidationError` (a subclass of `ValueError`). This also expects that the schemas assume that omitting required in the schema asserts the field is optional, not required. This is due to upstream schemas being in JSON Schema v3, and not validictory's modified syntax. """ if schema is None: schema = self._schema validator = utils.DatetimeValidator(required_by_default=False) validator.validate(self.as_dict(), schema)
def validate(self, schema=None): """ Validate that we have a valid object. On error, this will raise a `ScrapeValueError` This also expects that the schemas assume that omitting required in the schema asserts the field is optional, not required. This is due to upstream schemas being in JSON Schema v3, and not validictory's modified syntax. """ if schema is None: schema = self._schema validator = utils.DatetimeValidator(required_by_default=False, fail_fast=False) try: validator.validate(self.as_dict(), schema) except ValidationError as ve: raise ScrapeValueError('validation of {} {} failed: {}'.format( self.__class__.__name__, self._id, ve))