Lazily validate the storage constraints, ensuring that they are a dict.

    Use the given add_error callable to register validation error.
422784
def _validate_storage(storage, service_name, add_error):
    
    if storage is None:
        return
    if not isdict(storage):
        msg = 'service {} has invalid storage constraints {}'.format(
            service_name, storage)
        add_error(msg)
269981
def augment_usage_errors(ctx, param=None):
    
    try:
        yield
    except BadParameter as e:
        if e.ctx is None:
            e.ctx = ctx
        if param is not None and e.param is None:
            e.param = param
        raise
    except UsageError as e:
        if e.ctx is None:
            e.ctx = ctx
        raise
1103275
def add_error(self, error):
        
        if is_non_string_iterable(error) and not isinstance(error, collections.Mapping):
            for value in error:
                self.add_error(value)
        else:
            self.append(error)
1220352
def _validate_function(self, func, name):
        
        test_feature = self.data['features'][0]
        if not callable(func) or not isinstance(func(test_feature), dict):
            raise ValueError('{} should be a function that accepts items from '
                             'data[\'features\'] and returns a dictionary.'
                             .format(name))
399195
def validate(self, data, context=None):
        
        try:
            self.load(data, context)
            return None
        except ValidationError as ve:
            return ve.messages
612644
def validate(self, instance, value):
        
        if not self.coerce and not isinstance(value, self._class_container):
            self.error(instance, value)
        if self.coerce and not isinstance(value, CONTAINERS):
            value = [value]
        if not isinstance(value, self._class_container):
            out_class = self._class_container
        else:
            out_class = value.__class__
        out = []
        for val in value:
            try:
                out += [self.prop.validate(instance, val)]
            except ValueError:
                self.error(instance, val, extra='This item is invalid.')
        return out_class(out)
433602
def validate(context_name = default_validation_context)
      errors.clear
      validation_violations(context_name).each { |v| errors.add(v) }

      self
    end
581500
def _validate_output_data(
        self, original_res, serialized_res, formatted_res, request):
        

        validator = self.representation

        # when not to validate...
        if not validator:
            return

        try:
            if isinstance(serialized_res, (list, tuple)):
                map(validator.validate, serialized_res)
            else:
                validator.validate(serialized_res)
        except ValidationError, exc:
            self._output_validation_failed(exc, serialized_res, request)
1342514
def validate(self):
        
        errors = []
        for param in self.required_params:
            if (not hasattr(self, param) or getattr(self, param) is None):
                errors.append("missing %s parameter" % (param))
        if (len(errors) > 0):
            raise IIIFInfoError("Bad data for info.json: " + ", ".join(errors))
        return True
691087
def _validate_items(self, path, obj, _):
        
        errs = []

        if obj.type == 'void':
            errs.append('void is only allowed in Operation object.')

        return path, obj.__class__.__name__, errs
585056
def validate_arguments(self, locals_dict):
        '''
        
        '''

        for key, value, validator in self.__map_arguments(locals_dict):
            if not self.__is_valid(value, validator):
                key_name = repr(key)
                func_name = self.__function.__name__
                annotation = self.__argument_annotation.get(key)
                message = self.ARG_TYPE_ERROR_MESSAGE.format(
                    key_name,
                    func_name,
                    self.__format_expectation(annotation),
                    value.__class__.__name__)
                raise TypesafetyError(message)
1234841
def addError(self, test: unittest.case.TestCase, exc_info: tuple) -> None:
        
        # noinspection PyTypeChecker
        self.add_result(TestState.error, test, exc_info)
1034005
def validate(self, value):
    
    if value is not None and not isinstance(value, self.data_type):
      raise datastore_errors.BadValueError(
          "Property %s must be convertible to a %s instance (%s)" %
          (self.name, self.data_type, value))
    return super(JsonProperty, self).validate(value)
819840
def callable_validator(v: Any) -> AnyCallable:
    
    if callable(v):
        return v

    raise errors.CallableError(value=v)
76555
def with_validator(self, validator):
    """"""
    if not callable(validator):
      raise ValueError('Validator must be callable', validator)
    self.validators.append(validator)
    self._cached = None
    return self
886709
def _validate_maxlength(self, max_length, field, value):
        
        if isinstance(value, Iterable) and len(value) > max_length:
            self._error(field, errors.MAX_LENGTH, len(value))
1099102
def _build_dict_validator(dictionary):
    """"""
    mandatory, optional, types, defaults = _determine_keys(dictionary)

    def dict_validator(data):
        """Validate dictionaries."""
        missing = list(defaults.keys())
        if not isinstance(data, dict):
            raise NotValid('%r is not of type dict' % (data,))

        validated = {}
        to_validate = list(data.keys())
        errors = _validate_mandatory_keys(
            mandatory, validated, data, to_validate)
        errors.extend(
            _validate_other_keys(
                optional, types, missing, validated, data, to_validate))
        if errors:
            raise NotValid(*errors)
        for key in missing:
            validated[key] = defaults[key][0]

        return validated

    return dict_validator