Validates mapper specification.

    Args:
      mapper_spec: an instance of model.MapperSpec to validate.
    Raises:
      BadWriterParamsError: when Output writer class mismatch.
775584
def validate(cls, mapper_spec):
    
    if mapper_spec.output_writer_class() != cls:
      raise errors.BadWriterParamsError("Output writer class mismatch")
    params = output_writers._get_params(mapper_spec)
    # Bucket Name is required
    if cls.BUCKET_NAME_PARAM not in params:
      raise errors.BadWriterParamsError(
          "%s is required for the _HashingGCSOutputWriter" %
          cls.BUCKET_NAME_PARAM)
262121
def kwargs_to_spec(self, **kwargs):
        

        spec = self.create_spec(**kwargs)
        self.prepare_spec(spec, **kwargs)
        return spec
715391
def _validate_param(rtype, fields):
    

    try:
        # raises ValueError if not found
        model = rtype_to_model(rtype)
        model_fields = model.all_fields
    except ValueError:
        raise InvalidQueryParams(**{
            'detail': 'The fields query param provided with a '
                      'field type of "%s" is unknown.' % rtype,
            'links': LINK,
            'parameter': PARAM,
        })

    for field in fields:
        if field not in model_fields:
            raise InvalidQueryParams(**{
                'detail': 'The fields query param "TYPE" of "%s" '
                          'is not possible. It does not have a field '
                          'by the name of "%s".' % (rtype, field),
                'links': LINK,
                'parameter': PARAM,
            })
72249
def validate(self):
        

        spec = self._create_specs()

        # support in future
        functions = {}

        validator = validate.Validator(functions=functions)

        self.config.configspec = spec
        result = self.config.validate(validator, preserve_errors=True)

        if self._parse_result(result):
            return True
118688
def _get_mapper_params(self):
    """"""
    reader_params = self.input_reader_cls.params_to_json(
        self.input_reader_params)
    # TODO(user): Do the same for writer params.
    return {"input_reader": reader_params,
            "output_writer": self.output_writer_params}
176092
def validate_paramified_params
      self.class.paramify_methods.each do |method|
        params = send(method)
        transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?
      end
    end
685270
def _validate_example(rh, method, example_type):
    
    example = getattr(method, example_type + "_example")
    schema = getattr(method, example_type + "_schema")

    if example is None:
        return None

    try:
        validate(example, schema)
    except ValidationError as e:
        raise ValidationError(
            "{}_example for {}.{} could not be validated.\n{}".format(
                example_type, rh.__name__, method.__name__, str(e)
            )
        )

    return json.dumps(example, indent=4, sort_keys=True)
353573
def _validate(self, writing=False):
        
        if self.brand not in ['jp2 ', 'jpx ']:
            msg = ("The file type brand was '{brand}'.  "
                   "It should be either 'jp2 ' or 'jpx '.")
            msg = msg.format(brand=self.brand)
            if writing:
                raise IOError(msg)
            else:
                warnings.warn(msg, UserWarning)
        for item in self.compatibility_list:
            if item not in self._valid_cls:
                msg = ("The file type compatibility list {items} is "
                       "not valid.  All items should be members of "
                       "{valid_entries}.")
                msg = msg.format(items=self.compatibility_list,
                                 valid_entries=self._valid_cls)
                if writing:
                    raise IOError(msg)
                else:
                    warnings.warn(msg, UserWarning)
387304
def validation_error_message(cls, spec, backends=None):
        
        try:
            cls.validate_spec(spec, backends=backends)
        except OptionError as e:
            return e.format_options_error()
1126645
def validate_type(self, type_):
        
        if type_ is not None and type_ not in self.types_set:
            raise ValueError('Invalid type for %s:%s' % (self.__class__, type_))
423405
function checkValidators(spec) {
  if (!spec.validate) return;

  let text;
  if (spec.validate.body) {
    text = 'validate.type must be declared when using validate.body';
    assert(/json|form/.test(spec.validate.type), text);
  }

  if (spec.validate.type) {
    text = 'validate.type must be either json, form, multipart or stream';
    assert(/json|form|multipart|stream/i.test(spec.validate.type), text);
  }

  if (spec.validate.output) {
    spec.validate._outputValidator = new OutputValidator(spec.validate.output);
  }

  // default HTTP status code for failures
  if (!spec.validate.failure) {
    spec.validate.failure = 400;
  }
}
1122256
def _validate_params_types(self, method, params):
        
        if isinstance(params, list):
            if not isinstance(self.method_data[method]['types'], list):
                raise InvalidParamsError(
                    'expected keyword params, not positional')

            for param, type, posnum in zip(params,
                                           self.method_data[method]['types'],
                                           range(1, len(params)+1)):
                if not (isinstance(param, type) or param is None):
                    raise InvalidParamsError(
                        'positional arg #{} is the wrong type'.format(posnum))

        elif isinstance(params, dict):
            if not isinstance(self.method_data[method]['types'], dict):
                raise InvalidParamsError(
                    'expected positional params, not keyword')

            if 'required' in self.method_data[method]:
                for key in self.method_data[method]['required']:
                    if key not in params:
                        raise InvalidParamsError('missing key: %s' % key)

            for key in params.keys():
                if key not in self.method_data[method]['types'] or \
                    not (isinstance(params[key],
                                    self.method_data[method]['types'][key])
                         or params[key] is None):
                    raise InvalidParamsError(
                        'arg "{}" is the wrong type'.format(key))
1186670
def validate(src, **kwargs):
    
    resolver = Resolver()
    validator = OcrdZipValidator(resolver, src)
    report = validator.validate(**kwargs)
    print(report)
    if not report.is_valid:
        sys.exit(1)
330624
def split_input(cls, mapper_spec):
    
    batch_size = int(_get_params(mapper_spec).get(
        cls.BATCH_SIZE_PARAM, cls._BATCH_SIZE))
    shard_count = mapper_spec.shard_count
    namespace_ranges = namespace_range.NamespaceRange.split(shard_count,
                                                            contiguous=True)
    return [NamespaceInputReader(ns_range, batch_size)
            for ns_range in namespace_ranges]
1162038
def validate(self):
        
        validator = Draft7Validator(self.SCHEMA)

        errors = set()  # make errors a set to avoid duplicates

        for error in validator.iter_errors(self.serialize()):
            errors.add('.'.join(
                list(map(str, error.path)) + [error.message]
            ))

        if errors:
            raise JSONValidationException(type(self).__name__, errors)
309434
def _validate_configuration_type(self, configuration_type):
        

        if configuration_type.lower() != 'running' and configuration_type.lower() != 'startup':
            raise Exception(self.__class__.__name__, 'Configuration Type is invalid. Should be startup or running')
153051
def validate_work_spec(cls, work_spec):
        '''

        '''
        if 'name' not in work_spec:
            raise ProgrammerError('work_spec lacks "name"')
        if 'min_gb' not in work_spec or \
                not isinstance(work_spec['min_gb'], (float, int, long)):
            raise ProgrammerError('work_spec["min_gb"] must be a number')