Perform validation for *instance* and stores serialized data,
indexes and errors into local cache.
Return ``True`` if the instance is ready to be saved to database.
355311
def is_valid(self, instance):
        ''''''
        dbdata = instance.dbdata
        data = dbdata['cleaned_data'] = {}
        errors = dbdata['errors'] = {}
        #Loop over scalar fields first
        for field, value in instance.fieldvalue_pairs():
            name = field.attname
            try:
                svalue = field.set_get_value(instance, value)
            except Exception as e:
                errors[name] = str(e)
            else:
                if (svalue is None or svalue is '') and field.required:
                    errors[name] = ("Field '{0}' is required for '{1}'."
                                    .format(name, self))
                else:
                    if isinstance(svalue, dict):
                        data.update(svalue)
                    elif svalue is not None:
                        data[name] = svalue
        return len(errors) == 0
985586
def has(self, lang, instance):
        
        instance_key = TransCache._create_key(lang, instance)
        return instance_key in self.cache
359411
def verify(self, cls, id_field, id_val, obj_from_cache):
        
        return getattr(obj_from_cache, id_field) == id_val
1280601
def __verify_ready(self, creating=False):
        '''
        '''

        if len(self._value_ranges) == 0:
            self._logger.log(
                'crit',
                'Attribute value_ranges must have at least one value'
            )
            raise RuntimeWarning(
                'Attribute value_ranges must have at least one value'
            )
        if len(self._employers) == 0 and creating is False:
            self._logger.log('crit', 'Need to create employers')
            raise RuntimeWarning('Need to create employers')
304380
def validate_instance(instance):
    """"""
    excludes = settings.AUTOMATED_LOGGING['exclude']['model']

    for excluded in excludes:
        if (excluded in [instance._meta.app_label.lower(),
                         instance.__class__.__name__.lower()] or
                instance.__module__.lower().startswith(excluded)):
            return False

    return True
644205
public function save() :bool {
		
		// if an id already exists
		if($this->_['id']) {
			// we can update and return the number of affected rows (0 on error, 1 on success)
			return (bool) self::_update()
				->set($this->__toArray(true, true))
				->where(['id'=>$this->_['id']])
				->execute();
		}
		// this is a new record
		else {
			// try to insert it
			$inserted_object = self::create($this->__toArray(true, true));
			// if insertion succeeded, return true
			if($inserted_object) {
				// clone ourselves with what the database returneds, a full fledged object
				$this->replicate($inserted_object);
				// return success
				return true;
			}
			// didnt insert
			else {
				// failure feedback
				return false;
			}
		}
		
	}
899086
def validate_replicas(self, data):
        """"""
        environment = data.get('environment')
        if environment and environment.replicas:
            validate_replicas(data.get('framework'), environment.replicas)
1254939
def valid(self, instance, schema):
        """"""
        try:
            jsonschema.validate(instance, schema)
        except jsonschema.exceptions.ValidationError as ex:
            self.stderr.write("    VALIDATION ERROR: {}".format(instance['name'] if 'name' in instance else ''))
            self.stderr.write("        path:       {}".format(ex.path))
            self.stderr.write("        message:    {}".format(ex.message))
            self.stderr.write("        validator:  {}".format(ex.validator))
            self.stderr.write("        val. value: {}".format(ex.validator_value))
            return False

        try:
            # Check that default values fit field schema.
            for field in ['input', 'output', 'schema']:
                for schema, _, path in iterate_schema({}, instance.get(field, {})):
                    if 'default' in schema:
                        validate_schema({schema['name']: schema['default']}, [schema])
        except ValidationError:
            self.stderr.write("    VALIDATION ERROR: {}".format(instance['name']))
            self.stderr.write("        Default value of field '{}' is not valid.". format(path))
            return False

        return True
1096560
def ready_validations_pass?
      self.class.ready_validations.all? do |validation|
        passed, message = instance_eval(&validation)
        self.ready_error = message if message && !passed
        passed
      end
    end
931440
def validate(self):
        

        validate_properties(self._data_map, self._metadata_props)

        for prop in self._data_map:
            validate_any(prop, getattr(self, prop), self._data_structures.get(prop))

        return self
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
905530
def save(self):
        
        resp = self._client.put(type(self).api_endpoint, model=self,
            data=self._serialize())

        if 'error' in resp:
            return False
        return True
1022248
def save(self, **kwargs):
        
        # Guard against incorrect use of `serializer.save(commit=False)`
        assert 'commit' not in kwargs, (
            "'commit' is not a valid keyword argument to the 'save()' method. "
            "If you need to access data before committing to the database then "
            "inspect 'serializer.validated_data' instead. "
            "You can also pass additional keyword arguments to 'save()' if you "
            "need to set extra attributes on the saved model instance. "
            "For example: 'serializer.save(owner=request.user)'.'"
        )

        validated_data = [
            dict(list(attrs.items()) + list(kwargs.items()))
            for attrs in self.validated_data
        ]

        if self.instance is not None:
            self.instance = self.update(self.instance, validated_data)
            assert self.instance is not None, (
                '`update()` did not return an object instance.'
            )
        else:
            self.instance = self.create(validated_data)
            assert self.instance is not None, (
                '`create()` did not return an object instance.'
            )

        return self.instance
298501
async def save(self, db=None):
        '''
        
        '''
        self._db = db or self.db
        data = self.prepare_data()
        # validate object
        self.validate()
        # connect to DB to save the model
        for i in self.connection_retries():
            try:
                created = False if '_id' in data else True
                result = await self.db[self.get_collection_name()].insert_one(data)
                self._id = result.inserted_id
                # emit post save
                asyncio.ensure_future(post_save.send(
                    sender=self.__class__,
                    db=self.db,
                    instance=self,
                    created=created)
                )
                break
            except ConnectionFailure as ex:
                exceed = await self.check_reconnect_tries_and_wait(i, 'save')
                if exceed:
                    raise ex
190172
def storage=(storage)
      validator = EnumAttributeValidator.new('String', ['cache'])
      unless validator.valid?(storage)
        fail ArgumentError, 'invalid value for "storage", must be one of #{validator.allowable_values}.'
      end
      @storage = storage
    end
920520
def validate_collection_association(reflection)
        if association = association_instance_get(reflection.name)
          if records = associated_records_to_validate_or_save(association, new_record?, reflection.options[:autosave])
            records.each_with_index { |record, index| association_valid?(reflection, record, index) }
          end
        end
      end
1109485
def validate(self, data):
        
        validator = self._schema.validator(self._id)
        validator.validate(data)