will make sure that specific data is correctly formatted for the database
163414
def deal_with_abnormalaties

      self.cover_image = upload_images(cover_image, id.to_s, 'terms') if cover_image.class != String && cover_image.class != NilClass

      # if the slug is empty it will take the name and create a slug
      self.slug =
        if slug.blank?
          name.gsub(' ', '-').downcase.gsub(/[^a-z0-9\-\s]/i, '')
        else
          slug.gsub(' ', '-').downcase.gsub(/[^a-z0-9\-\s]/i, '')
        end

      self.structured_url = '/' + self.slug

    end
764984
void checkDataReadOnly() {

        if (dataSource.length() == 0) {
            throw Error.error(ErrorCode.TEXT_TABLE_UNKNOWN_DATA_SOURCE);
        }

        if (isReadOnly) {
            throw Error.error(ErrorCode.DATA_IS_READONLY);
        }
    }
354942
def __quick_validate(r, check=('ResultSet', 'Result', 'totalRecords')):
    '''
    
    '''
    if 'ResultSet' in check and 'ResultSet' not in r:
        raise ResultSetError('no ResultSet in server response')
    if 'Result' in check and 'Result' not in r['ResultSet']:
        raise ResultSetError('no Result in server response')
    if 'totalRecords' in check and 'totalRecords' not in r['ResultSet']:
        raise ResultSetError('no totalRecords in server response')
    return True
618419
public static function ensureCorrectFieldsEncodingOnUpdate()
    {
        $dbMetaDataHandler = oxNew(\OxidEsales\Eshop\Core\DbMetaDataHandler::class);
        if ($dbMetaDataHandler->tableExists("oepaypal_order")) {
            $query = "ALTER TABLE `oepaypal_order` DEFAULT CHARACTER SET utf8 collate utf8_general_ci;";
            \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute($query);

            $query = "ALTER TABLE `oepaypal_orderpaymentcomments` DEFAULT CHARACTER SET utf8 collate utf8_general_ci;";
            \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute($query);

            $query = "ALTER TABLE `oepaypal_orderpayments`  DEFAULT CHARACTER SET utf8 collate utf8_general_ci;";
            \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute($query);

            $query = "ALTER TABLE `oepaypal_order` 
              MODIFY `OEPAYPAL_CURRENCY` varchar(32) character set utf8 collate utf8_general_ci NOT NULL,
              MODIFY `OEPAYPAL_PAYMENTSTATUS` enum('pending','completed','failed','canceled') CHARACTER SET utf8 collate utf8_general_ci NOT NULL DEFAULT 'pending',
              MODIFY `OEPAYPAL_TRANSACTIONMODE` enum('Sale','Authorization') CHARACTER SET utf8 collate utf8_general_ci NOT NULL DEFAULT 'Sale';";
            \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute($query);

            $query = "ALTER TABLE `oepaypal_orderpaymentcomments` 
              MODIFY `OEPAYPAL_COMMENT` varchar(256) character set utf8 collate utf8_general_ci NOT NULL;";
            \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute($query);

            $query = "ALTER TABLE `oepaypal_orderpayments` 
                MODIFY `OEPAYPAL_ACTION` enum('capture','authorization','re-authorization','refund','void') CHARACTER SET utf8 collate utf8_general_ci NOT NULL DEFAULT 'capture',
                MODIFY `OEPAYPAL_TRANSACTIONID` varchar(32) character set utf8 collate utf8_general_ci NOT NULL,
                MODIFY `OEPAYPAL_CORRELATIONID` varchar(32) character set utf8 collate utf8_general_ci NOT NULL,
                MODIFY `OEPAYPAL_CURRENCY` varchar(3) character set utf8 collate utf8_general_ci NOT NULL,
                MODIFY `OEPAYPAL_STATUS` varchar(20) character set utf8 collate utf8_general_ci NOT NULL;";
            \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute($query);
        }
    }
506811
private function validateDatabase()
    {
        /*
        * Check Database Connection
        */
        $dsn = $this->DBConnectComand();
        try {
            $DBConnection = new \PDO($dsn, $this->DB_USERNAME, $this->DB_PASSWORD, array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION));
        }
        catch (PDOException $ex) {
            throw new \Exception('Connection to database failed: ' . $ex->getMessage());
        }

        /*
         * Check if the database is empty on install
         */
        if(!$this->isInstalled) {
            $tables = 0;
            $fetch = $this->checkDatabase($DBConnection);
            while ($result = $fetch->fetch()){
                $tables++;
                break;
            }
            if ($tables > 0) {
                throw new \Exception('Database "' . $this->DB_DATABASE . '" is not empty. Please empty the database or specify another database.');
            }
        }

        return;
    }
772743
def _validate_data(data):
    
    data_keys = set(data.keys())
    extra_keys = data_keys - set(ALLOWED_KEYS)
    missing_keys = set(REQUIRED_KEYS) - data_keys

    if extra_keys:
        raise ValueError(
            'Invalid data keys {!r}'.format(', '.join(extra_keys))
        )

    if missing_keys:
        raise ValueError(
            'Missing keys {!r}'.format(', '.join(missing_keys))
        )
56420
protected function _isValidFormat()
	{
		//	Reading 2048 bytes should be enough to validate that the format is HTML
		$data = fread($this->_fileHandle, 2048);
		if ((strpos($data, '<') !== FALSE) &&
			(strlen($data) !== strlen(strip_tags($data)))) {
			return TRUE;
		}

		return FALSE;
	}
827051
function checkIfCreated(ID, money) {
                    db.get(`SELECT * FROM economy WHERE userID = '${ID}'`, (err, row) => {
                        if (!row) {
                            insertFirstMoney(ID);
                        } else {
                            db.run(`UPDATE economy SET money = '${money}' WHERE userID = '${ID}'`);
                            db.get(`SELECT * FROM economy WHERE userID = '${ID}'`, (err, row) => {
                                resolveDB(row);
                            });
                        }
                    });
                }
711285
def get_db_prep_save(self, value, connection, prepared=False):
        
        log.debug("get_db_prep_save: {}, {}", value, type(value))
        if not value:
            return ''
            # For underlying (database) string types, e.g. VARCHAR, this
            # function must always return a string type.
            # https://docs.djangoproject.com/en/1.8/howto/custom-model-fields/
        return python_localized_datetime_to_human_iso(value)
83051
def ensure_table(self, cls):
        """"""
        id_len = len(uuid())
        index_names = cls.index_names() or []
        cols = [
            'id char(%d) primary key' % (id_len,),
            'value jsonb'
        ] + [
            name + ' text' for name in index_names
        ]

        table_name = cls.get_table_name()

        with self._conn() as conn:
            with conn.cursor() as cur:
                cur.execute('create table if not exists %s (%s);' % (
                    table_name,
                    ','.join(cols)
                ))
                for name in index_names:
                    cur.execute('create index if not exists %s on %s(%s);' % (
                        table_name + '_' + name + '_idx',
                        table_name,
                        name
                    ))
1350028
def data_string_compare(db_data, user_data):
        
        db_data = ''.join(db_data.split())
        user_data = ''.join(user_data.split())
        if operator.eq(db_data, user_data):
            return True
        return False
1325958
def validate(self, data, offset):
        """"""
        recorded_checksum = self.field.getval()

        # convert negative offset to positive
        if offset < 0:
            offset += len(data)

        # replace checksum region with zero
        data = b''.join((data[:offset],
                         b"\x00" * self.bytes_required,
                         data[offset + self.bytes_required:]))
        actual_checksum = self.algo(data[self.start:self.end])
        if recorded_checksum != actual_checksum:
            raise SuitcaseChecksumException(
                "recorded checksum %r did not match actual %r.  full data: %r",
                recorded_checksum, actual_checksum, data)
1265974
def _CheckCollation(cursor):
  """"""

  # Do not fail for wrong collation, because changing it is harder than changing
  # the character set. Some providers only allow changing character set and then
  # use the default collation. Also, misconfigured collation is not expected to
  # have major negative impacts, since it only affects string sort order for
  # some locales.

  cur_collation_connection = _ReadVariable("collation_connection", cursor)
  if cur_collation_connection != COLLATION:
    logging.warning("Require MySQL collation_connection of %s, got %s.",
                    COLLATION, cur_collation_connection)

  cur_collation_database = _ReadVariable("collation_database", cursor)
  if cur_collation_database != COLLATION:
    logging.warning(
        "Require MySQL collation_database of %s, got %s."
        " To create your database, use: %s", COLLATION, cur_collation_database,
        CREATE_DATABASE_QUERY)
1051692
function validate (o) {
  if (-1 === o.db.w || 0 === o.db.w) {
    if (o.db.journal || o.db.fsync || o.db.safe) {
      throw new Error(
          'Invalid writeConcern: '
        + 'w set to -1 or 0 cannot be combined with safe|fsync|journal');
    }
  }
}
927130
def _ensure_field(self, key):
        """"""
        if self._has_field:
            self._size += 2  # comma, space
        self._has_field = True

        self._size += len(key) + 4
24084
function checkSavedData(dbName, objStore, data) {
    const keyValueContainer = Object.prototype.isPrototypeOf.call(skladKeyValueContainer, data);
    const value = keyValueContainer ? data.value : data;
    const objStoreMeta = objStoresMeta.get(dbName).get(objStore.name);
    let key = keyValueContainer ? data.key : undefined;

    const keyPath = objStore.keyPath || objStoreMeta.keyPath;
    const autoIncrement = objStore.autoIncrement || objStoreMeta.autoIncrement;

    if (keyPath === null) {
        if (!autoIncrement && key === undefined) {
            key = uuid();
        }
    } else {
        if (typeof data !== 'object') {
            return false;
        }

        // TODO: support dot-separated and array keyPaths
        if (!autoIncrement && data[keyPath] === undefined) {
            data[keyPath] = uuid();
        }
    }

    return key ? [value, key] : [value];
}
531983
protected function isValidFormat()
    {
        // Read sample data (first 2 KB will do)
        $data = fread($this->fileHandle, 2048);

        // Count delimiters in file
        $delimiterCount = substr_count($data, ';');
        if ($delimiterCount < 1) {
            return false;
        }

        // Analyze first line looking for ID; signature
        $lines = explode("\n", $data);
        if (substr($lines[0], 0, 4) != 'ID;P') {
            return false;
        }

        return true;
    }