Validate the type_registry option.
342932
def validate_type_registry(option, value):
    """"""
    if value is not None and not isinstance(value, TypeRegistry):
        raise TypeError("%s must be an instance of %s" % (
            option, TypeRegistry))
    return value
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')
1031563
def Validate(self, type_names):
    """"""
    errs = [n for n in self._RDFTypes(type_names) if not self._GetClass(n)]
    if errs:
      raise DefinitionError("Undefined RDF Types: %s" % ",".join(errs))
1096169
def _determine_validator_type(self, data_type, value, has_default):
        """"""
        data_type, nullable = unwrap_nullable(data_type)

        validator = None

        if is_list_type(data_type):
            item_validator = self._determine_validator_type(
                data_type.data_type, value, False)
            item_validator = item_validator if item_validator else 'nil'

            validator = '{}:{}'.format(
                fmt_validator(data_type),
                fmt_func_args([
                    ('minItems', '@({})'.format(data_type.min_items)
                     if data_type.min_items else 'nil'),
                    ('maxItems', '@({})'.format(data_type.max_items)
                     if data_type.max_items else 'nil'),
                    ('itemValidator', item_validator),
                ]))
        elif is_map_type(data_type):
            item_validator = self._determine_validator_type(
                data_type.value_data_type, value, False)
            item_validator = item_validator if item_validator else 'nil'

            validator = '{}:{}'.format(
                fmt_validator(data_type),
                fmt_func_args([
                    ('itemValidator', item_validator),
                ]))
        elif is_numeric_type(data_type):
            if data_type.min_value or data_type.max_value:
                validator = '{}:{}'.format(
                    fmt_validator(data_type),
                    fmt_func_args([
                        ('minValue', '@({})'.format(data_type.min_value)
                         if data_type.min_value else 'nil'),
                        ('maxValue', '@({})'.format(data_type.max_value)
                         if data_type.max_value else 'nil'),
                    ]))
        elif is_string_type(data_type):
            if data_type.pattern or data_type.min_length or data_type.max_length:
                pattern = data_type.pattern.encode('unicode_escape').replace(
                    "\"", "\\\"") if data_type.pattern else None
                validator = '{}:{}'.format(
                    fmt_validator(data_type),
                    fmt_func_args([
                        ('minLength', '@({})'.format(data_type.min_length)
                         if data_type.min_length else 'nil'),
                        ('maxLength', '@({})'.format(data_type.max_length)
                         if data_type.max_length else 'nil'),
                        ('pattern', '@"{}"'.format(pattern)
                         if pattern else 'nil'),
                    ]))

        if nullable:
            if validator:
                validator = fmt_func_call(
                    caller='DBStoneValidators', callee=validator)
                validator = fmt_func_call(
                    caller='DBStoneValidators',
                    callee='nullableValidator',
                    args=validator)
        else:
            if validator:
                validator = fmt_func_call(
                    caller='DBStoneValidators', callee=validator)
            else:
                validator = 'nil'
            if not has_default:
                validator = fmt_func_call(
                    caller='DBStoneValidators',
                    callee='nonnullValidator',
                    args=validator)
            else:
                validator = None
        return validator
94921
def is_registered(ext):
    '''  '''
    return Lean.template_mappings.has_key(ext.lower()) and len(Lean.template_mappings[ext])
141831
def type_check(self, filename):
        """"""
        self.log.debug('type_check: in')
        self.editor.clean_errors()
        self.send_request(
            {"typehint": "TypecheckFilesReq",
             "files": [self.editor.path()]})
1175448
def validate_types(self, types=None):
        
        types = types or self.default_types
        if types is None:
            types = []
        if isinstance(types, six.string_types):
            types = [types]
        return types
330174
function validate (type, value) {
  const { t } = readType(type)
  if (value === undefined || value === null) return { require: true }

  switch (t) {
    case SOPHIA_TYPES.int:
      return isNaN(value) || ['boolean'].includes(typeof value)
    case SOPHIA_TYPES.bool:
      return typeof value !== 'boolean'
    case SOPHIA_TYPES.address:
      return !(value[2] === '_' && ['ak', 'ct'].includes(value.slice(0, 2)))
    default:
      return false
  }
}
387160
def _validate(cls, kind):
        """"""
        if kind not in cls._valid_kinds:
            mesg = "'kind' must be one of {}, {}, {}, or {}."
            raise ValueError(mesg.format(*cls._valid_kinds))
        else:
            return kind
846906
def validate(cls, full_config: typing.Dict[str, typing.Any]) -> typing.Dict[str, typing.Any]:
        
        if cls.key is not None:
            if cls.key in full_config:
                return {cls.key: full_config[cls.key]}
            elif cls.required:
                return {cls.key: cls.default}
400262
public function verifySettings()
    {
        if ($this->type === null) {
            $this->setError("The type attribute is required");
        } elseif (!in_array($this->type, self::$types, true)) {
            $this->setError("Invalid type specified; must be one of (" . implode(self::$types) . ")");
        }
    }
411295
def IOC_TYPECHECK(t):
    
    result = ctypes.sizeof(t)
    assert result <= _IOC_SIZEMASK, result
    return result
167923
def validate_field_matches_type(field, value, field_type, select_items=None, _min=None, _max=None):
    """"""
    if (field_type == defs.TEXT_TYPE and not isinstance(value, six.string_types)) or \
       (field_type == defs.STRING_TYPE and not isinstance(value, six.string_types)) or \
       (field_type == defs.BOOLEAN_TYPE and not isinstance(value, bool)) or \
       (field_type == defs.INTEGER_TYPE and not isinstance(value, int)):
        raise exceptions.ConfigFieldTypeMismatch(field, value, field_type)

    if field_type == defs.INTEGER_TYPE:
        if _min and value < _min:
            raise exceptions.ConfigFieldTypeMismatch(field, value, "must be higher than {}".format(_min))
        if _max and value > _max:
            raise exceptions.ConfigFieldTypeMismatch(field, value, "must be lower than {}".format(_max))

    if field_type == defs.SELECT_TYPE:
        from honeycomb.utils.plugin_utils import get_select_items
        items = get_select_items(select_items)
        if value not in items:
            raise exceptions.ConfigFieldTypeMismatch(field, value, "one of: {}".format(", ".join(items)))
1317691
def _validate_type(self):  # type: () -> None
        """"""
        if not isinstance(self._value, self._type):
            title = '{} has an invalid type'.format(self._key_name())
            description = '{} must be a {}'.format(self._key_name(), self._type.__name__)

            self._add_error(title=title, description=description)
581152
def _validate_opts(opts):
    '''
    
    '''
    def format_multi_opt(valid_type):
        try:
            num_types = len(valid_type)
        except TypeError:
            # Bare type name won't have a length, return the name of the type
            # passed.
            return valid_type.__name__
        else:
            def get_types(types, type_tuple):
                for item in type_tuple:
                    if isinstance(item, tuple):
                        get_types(types, item)
                    else:
                        try:
                            types.append(item.__name__)
                        except AttributeError:
                            log.warning(
                                'Unable to interpret type %s while validating '
                                'configuration', item
                            )
            types = []
            get_types(types, valid_type)

            ret = ', '.join(types[:-1])
            ret += ' or ' + types[-1]
            return ret

    errors = []

    err = (
        'Config option \'{0}\' with value {1} has an invalid type of {2}, a '
        '{3} is required for this option'
    )
    for key, val in six.iteritems(opts):
        if key in VALID_OPTS:
            if val is None:
                if VALID_OPTS[key] is None:
                    continue
                else:
                    try:
                        if None in VALID_OPTS[key]:
                            continue
                    except TypeError:
                        # VALID_OPTS[key] is not iterable and not None
                        pass

            if isinstance(val, VALID_OPTS[key]):
                continue

            # We don't know what data type sdb will return at run-time so we
            # simply cannot check it for correctness here at start-time.
            if isinstance(val, six.string_types) and val.startswith('sdb://'):
                continue

            if hasattr(VALID_OPTS[key], '__call__'):
                try:
                    VALID_OPTS[key](val)
                    if isinstance(val, (list, dict)):
                        # We'll only get here if VALID_OPTS[key] is str or
                        # bool, and the passed value is a list/dict. Attempting
                        # to run int() or float() on a list/dict will raise an
                        # exception, but running str() or bool() on it will
                        # pass despite not being the correct type.
                        errors.append(
                            err.format(
                                key,
                                val,
                                type(val).__name__,
                                VALID_OPTS[key].__name__
                            )
                        )
                except (TypeError, ValueError):
                    errors.append(
                        err.format(key,
                                   val,
                                   type(val).__name__,
                                   VALID_OPTS[key].__name__)
                    )
                continue

            errors.append(
                err.format(key,
                           val,
                           type(val).__name__,
                           format_multi_opt(VALID_OPTS[key]))
            )

    # Convert list to comma-delimited string for 'return' config option
    if isinstance(opts.get('return'), list):
        opts['return'] = ','.join(opts['return'])

    for error in errors:
        log.warning(error)
    if errors:
        return False
    return True
1012009
def check(name, type=None, context=None, position=None):
    
    def decorator(func):
        registry.register_check(func, name, type, context, position)
        return func
    return decorator
778305
def _validate_and_get_value(options, options_name, key, _type):
  
  if isinstance(options, dict):
    has = lambda k: k in options
    get = lambda k: options[k]
  elif isinstance(options, object):
    has = lambda k: hasattr(options, k)
    get = lambda k: getattr(options, k)
  else:
    raise ImproperlyConfigured(
        '`{}` must be a dictionary-like object.'.format(options_name))

  if not has(key):
    raise ImproperlyConfigured(
        '`{}` must be specified in `{}`'.format(key, options_name))

  value = get(key)
  if not isinstance(value, _type):
    raise ImproperlyConfigured(
        '`{}` in `{}` must be a {}'.format(key, options_name, repr(_type)))

  return value