Determine and validate the active model type.
493608
def get_model_type(model_type, config):
    """"""

    # If no model type is given, then check the config file
    if not model_type:
        model_type = config.get('model')

    # If there is still no model type, try the parent directory
    if not model_type:
        model_type = os.path.basename(os.path.abspath(os.pardir))
        print('payu: warning: Assuming model is {0} based on parent directory '
              'name.'.format(model_type))

    if model_type not in supported_models:
        print('payu: error: Unknown model {0}'.format(model_type))
        sys.exit(-1)
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)
1077210
def _validate_type(self, item, name):
        """"""
        if item is None:
            # don't validate None items, since they'll be caught by the portion
            # of the validator responsible for handling `required`ness
            return

        if not isinstance(item, self.allowed_types):
            item_class_name = item.__class__.__name__
            raise ArgumentError(name,
                "Expected one of %s, but got `%s`" % (
                    self.allowed_types, item_class_name))
1063491
private boolean checkEDBObjectModelType(EDBObject object, Class<?> model) {
        String modelClass = object.getString(EDBConstants.MODEL_TYPE);
        if (modelClass == null) {
            LOGGER.warn(String.format("The EDBObject with the oid %s has no model type information."
                    + "The resulting model may be a different model type than expected.", object.getOID()));
        }
        if (modelClass != null && !modelClass.equals(model.getName())) {
            return false;
        }
        return true;
    }
420985
public function validateModelClass()
    {
        if ($this->isReservedKeyword($this->modelClass)) {
            $this->addError('modelClass', 'Class name cannot be a reserved PHP keyword.');
        }
        if ((empty($this->indexName) || substr_compare($this->indexName, '*', -1, 1)) && $this->modelClass == '') {
            $this->addError('modelClass', 'Model Class cannot be blank if table name does not end with asterisk.');
        }
    }
726640
def validate(self, model, checks=[]):
        """"""
        records = self.data.to_dict("records")
        self.evaluate_report(
            validate(records, headers=list(records[0]),
                     preset='table', schema=self.schema,
                     order_fields=True, custom_checks=checks))
271235
def validate(cls, event_info):
        """"""
        assert 'service_key' in event_info
        assert isinstance(event_info['service_key'], six.string_types)
        assert 'event_type' in event_info
        assert event_info['event_type'] in cls.EVENT_TYPES
        if event_info['event_type'] != cls.EVENT_TYPES[0]:
            assert 'incident_key' in event_info
            assert isinstance(event_info['incident_key'], six.string_types)
        else:
            assert 'description' in event_info

        if 'details' in event_info:
            assert isinstance(event_info['details'], dict)

        if 'contexts' in event_info:
            assert isinstance(event_info['contexts'], (list, tuple,))
1232149
protected function checkModelType($model)
    {
        if (is_string($model)) {
            return $this->getTable($model);
        } elseif (is_object($model)) {
            return $this->getTable(get_class($model));
        }
    }
811328
def validate(self) :
        """"""
        self._store.validate()
        for pField in self.collection.arangoPrivates :
            self.collection.validatePrivate(pField, getattr(self, pField))
1358371
function(attrs, options) {
      if (attrs instanceof Model) {
        if (!attrs.collection) attrs.collection = this;
        return attrs;
      }
      options || (options = {});
      options.collection = this;
      var model = new this.model(attrs, options);
      if (!model._validate(attrs, options)) {
        this.trigger('invalid', this, attrs, options);
        return false;
      }
      return model;
    }
991568
def validate(self):
        """"""
        try:
            # update _resource to have default values from the schema
            self._resource = self.schema(self._resource)
        except MultipleInvalid as e:
            errors = [format_error(err, self.resource_type) for err in e.errors]
            raise exceptions.ValidationError({'errors': errors})

        yield self.check_unique()
912360
protected function performCheck()
    {
        // Parameter overrules automatic detection
        $column = head($this->parameters) ?: $this->determineActiveColumn();

        return ! $this->model->{$column};
    }
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
738336
protected function determineActiveColumn()
    {
        $info = $this->getModelInformation();

        if ($info && $info->list->activatable && $info->list->active_column) {
            return $info->list->active_column;
        }

        return 'active';
    }
633246
def determine_types(self):
        
        from nefertari.elasticsearch import ES
        collections = self.get_collections()
        resources = self.get_resources(collections)
        models = set([res.view.Model for res in resources])
        es_models = [mdl for mdl in models if mdl
                     and getattr(mdl, '_index_enabled', False)]
        types = [ES.src2type(mdl.__name__) for mdl in es_models]
        return types
1063616
private void confirmMatchForDsTypeModel(ValidationResult result,
                                            DsTypeModel typeModel,
                                            String contentModelPid,
                                            ObjectInfo object) {
        String id = typeModel.getId();
        DatastreamInfo dsInfo = object.getDatastreamInfo(id);
        if (dsInfo == null) {
            // If there is no datastream by that name, nothing to check.
            result.addNote(ValidationResultNotation
                    .noMatchingDatastreamId(contentModelPid, id));
            return;
        }

        Collection<Form> forms = typeModel.getForms();
        if (forms.isEmpty()) {
            // If the type model has no forms, it's an automatic match.
            return;
        }

        // Otherwise, the datastream must meet the constraints of at least one form.
        for (Form form : forms) {
            if (meetsConstraint(dsInfo.getMimeType(), form.getMimeType())
                    && meetsConstraint(dsInfo.getFormatUri(), form
                            .getFormatUri())) {
                return;
            }
        }
        result.addNote(ValidationResultNotation
                .datastreamDoesNotMatchForms(contentModelPid, id));
    }
294348
def validate_type(value, types, **kwargs):
    
    if not is_value_of_any_type(value, types):
        raise ValidationError(MESSAGES['type']['invalid'].format(
            repr(value), get_type_for_value(value), types,
        ))