Validate database details input
770165
protected function validateInputDbInstall()
    {
        $this->validatePrompt('database.name', $this->text('Database name'), 'install');
        $this->validatePrompt('database.user', $this->text('Database user'), 'install', 'root');
        $this->validatePrompt('database.password', $this->text('Database password'), 'install', '');
        $this->validatePrompt('database.port', $this->text('Database port'), 'install', '3306');
        $this->validatePrompt('database.host', $this->text('Database port'), 'install', 'localhost');

        $this->validateInputDbTypeInstall();
    }
959216
def validate_login(ctx, param, value):
    """"""
    # pylint: disable=unused-argument
    value = value.strip()
    if not value:
        raise click.BadParameter("The value cannot be blank.", param=param)
    return value
1321734
public function validate() {

		$app	= Application::getInstance();
		$value	= Input::get($this->name);
		$valid	= TRUE;

		if ($this->required) {
			
			switch ($this->type) {

				default:
				case 'text':
				case 'password':
				case 'date':
				case 'datetime':
				case 'file':
				case 'tel':
				case 'address':
				case 'color':
				case 'hidden':
					if (''==$value) {
						$app->logEvent('Control validation on field “' . $this->name . '” has failed (required)');
						$valid = FALSE;
					}
					break;

				case 'email':
					if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
						$app->logEvent('Control validation on field “' . $this->name . '” has failed (email required)');
						$valid = FALSE;
					}
					break;
					
				case 'url':
					if (!filter_var($value, FILTER_VALIDATE_URL)) {
						$app->logEvent('Control validation on field “' . $this->name . '” has failed (url required)');
						$valid = FALSE;
					}
					break;
					
				case 'number':
					if (!is_numeric($value)) {
						$app->logEvent('Control validation on field “' . $this->name . '” has failed (number required)');
						$valid = FALSE;
					}
					break;
				
				case 'bool':
					break;
					
			}
			
		}

		// set min and max value attribute for date and number only
		if (in_array($this->type, ['number','date'])) {
			
			if ($this->min and $value < $this->min) {
				$app->logEvent('Control validation on field “' . $this->name . '” has failed (min=' . $this->min . ')');
				$valid = FALSE;
			}
			
			if ($this->max and $value > $this->max) {
				$app->logEvent('Control validation on field “' . $this->name . '” has failed (max=' . $this->max . ')');
				$valid = FALSE;
			}
			
		}

		// check validity of minlength attribute
		if ($this->minLength and ''!=$value and strlen($value) < $this->minLength) {
			$app->logEvent('Control validation on field “' . $this->name . '” has failed (minLength=' . $this->minLength . ')');
			$valid = FALSE;
		}

		// check validity of minlength attribute
		if ($this->maxLength and strlen($value) > $this->maxLength) {
			$app->logEvent('Control validation on field “' . $this->name . '” has failed (maxLength=' . $this->maxLength . ')');
			$valid = FALSE;
		}
		
		return $valid;

	}
28811
def _validate_user_inputs(self, attributes=None, event_tags=None):
    

    if attributes and not validator.are_attributes_valid(attributes):
      self.logger.error('Provided attributes are in an invalid format.')
      self.error_handler.handle_error(exceptions.InvalidAttributeException(enums.Errors.INVALID_ATTRIBUTE_FORMAT))
      return False

    if event_tags and not validator.are_event_tags_valid(event_tags):
      self.logger.error('Provided event tags are in an invalid format.')
      self.error_handler.handle_error(exceptions.InvalidEventTagException(enums.Errors.INVALID_EVENT_TAG_FORMAT))
      return False

    return True
751078
function validate(cmd, args, info) {
  AbstractCommand.prototype.validate.apply(this, arguments);

  var source = '' + args[0]
    , destination = '' + args[1];

  if(!info.db.getKey(args[0], info)) {
    throw NoSuchKey;
  }else if(source === destination) {
    throw SourceDestination;
  }
  args[0] = source;
  args[1] = destination;
}
276613
def validate(schema):
    """"""
    try:
        tableschema.validate(schema)
        click.echo("Schema is valid")
        sys.exit(0)
    except tableschema.exceptions.ValidationError as exception:
        click.echo("Schema is not valid")
        click.echo(exception.errors)
        sys.exit(1)
970483
def validate_item(db, item)
      unless File.exist?("data_bags/#{db}/#{item}.json")
        STDERR.puts "ERROR: data bag '#{db}' item '#{item}' file 'data_bags/#{db}/#{item}.json' does not exist"
        exit(-1)
      end
      f = File.read("data_bags/#{db}/#{item}.json")
      begin
        itemfile = JSON.parse(f)
      rescue JSON::ParserError => e # invalid JSON
        STDERR.puts "ERROR: data bag '#{db} item '#{item}' has JSON errors."
        STDERR.puts e.message
        exit(-1)
      end
      # validate the id matches the file name
      item = item.split("/").last if item =~ /\// # pull out directories

      return if item.eql?(itemfile["id"])

      STDERR.puts "ERROR: data bag '#{db}' item '#{item}' listed in the manifest does not match the id '#{itemfile['id']}' within the 'data_bags/#{db}/#{item}.json' file."
      exit(-1)
    end
270292
def clean(self):
        ''''''
        data = super(SignupForm, self).clean()

        # basic check for now
        if 'username' in data:
            if User.objects.filter(
                    username=data['username'],
                    email=data['email']).exists():
                raise validators.ValidationError(
                    _('Username or email exists in database.'))

        if 'password' in data:
            if data['password'] != data.get('confirm_password', None):
                raise validators.ValidationError(_('Passwords do not match.'))
            else:
                data.pop('confirm_password')
        return data
895602
public function doDatabaseCheck()
    {
        $validator = new Validation\Database();
        $validator->setPathResolver($this->config->app['path_resolver']);
        $validator->setConfig($this->config->app['config']);
        $validator->check();
    }
1341133
def _validate_input(self, table: pd.DataFrame, failed_only=False) -> pd.DataFrame:
        """"""
        return self._do_validation_set(
            table=table,
            columns=self.input_columns,
            validation_type="input",
            failed_only=failed_only,)
1309397
def validate_value(self, value):
        """"""
        super(ValuesListField, self).validate_value(value)

        if value is not None:
            if value not in self.selection_to_id_map:
                raise ValidationError(
                    self.record,
                    'Field "{}" invalid value "{}". Valid options: {}'.format(
                        self.name,
                        value,
                        ', '.join(self.selection_to_id_map.keys())
                    )
                )
240695
function validateInformation( $http, $base,
                                  &$inputParameters, $validationParameters = array() )
    {
        $dataType = $this->dataType();
        if ( $dataType )
        {
            $this->setInputParameters( $inputParameters );
            $this->setValidationParameters( $validationParameters );
            $this->IsValid = $dataType->validateCollectionAttributeHTTPInput( $http, $base, $this );
            $this->unsetValidationParameters();
            $this->unsetInputParameters();
        }
        return $this->IsValid;
    }
101535
private function validateDatabaseDetails($environment)
    {
        $db_config = [];
        $configFile = DIR_CONFIG_SITE . '/database.php';
        $environmentConfig = DIR_CONFIG_SITE . "/{$environment}.database.php";

        // If the database.php file exists, load it first
        if (file_exists($configFile)) {
            $db_config = include DIR_CONFIG_SITE . '/database.php';
        }

        // If there's an environment specific database file, load that too
        if (file_exists($environmentConfig)) {
            $db_config = array_merge($db_config, include $environmentConfig);
        }

        // Make sure the default connection is set
        $defaultConnection = array_get($db_config, 'default-connection');

        // Make sure we have all the stuff we expect
        $connection = array_get($db_config, "connections.{$defaultConnection}");

        // Make sure we have all the keys we are expecting
        return $defaultConnection && $connection &&
            array_get($connection, 'database') &&
            array_get($connection, 'username') &&
            array_get($connection, 'server');
    }
610161
def _validate_information(self):
        """"""

        needed_variables = ["ModuleName", "ModuleVersion", "APIVersion"]

        for var in needed_variables:
            if var not in self.variables:
                raise DataError("Needed variable was not defined in mib file.", variable=var)

        # Make sure ModuleName is <= 6 characters
        if len(self.variables["ModuleName"]) > 6:
            raise DataError("ModuleName too long, must be 6 or fewer characters.",
                            module_name=self.variables["ModuleName"])

        if not isinstance(self.variables["ModuleVersion"], str):
            raise ValueError("ModuleVersion ('%s') must be a string of the form X.Y.Z" %
                             str(self.variables['ModuleVersion']))

        if not isinstance(self.variables["APIVersion"], str):
            raise ValueError("APIVersion ('%s') must be a string of the form X.Y" % str(self.variables['APIVersion']))

        self.variables['ModuleVersion'] = self._convert_module_version(self.variables["ModuleVersion"])
        self.variables['APIVersion'] = self._convert_api_version(self.variables["APIVersion"])
        self.variables["ModuleName"] = self.variables["ModuleName"].ljust(6)

        self.valid = True
3576
public function main()
    {
        $this->validate();

        $buf = "Database settings:\n"
            . " driver: " . ($this->databaseDriver ? $this->databaseDriver : "(default)" ). "\n"
            . " URL: " . $this->databaseUrl . "\n"
            . ($this->databaseUser ? " user: " . $this->databaseUser . "\n" : "")
            . ($this->databasePassword ? " password: " . $this->databasePassword . "\n" : "");

        $this->log($buf, Project::MSG_VERBOSE);

        // 1) First create the Data XML -> database name map.
        $this->createDataDbMap();

        // 2) Now go create the XML files from teh database(s)
        foreach ($this->getDataModels() as $dataModel) { // there is really one 1 db per datamodel
            foreach ($dataModel->getDatabases() as $database) {

                // if database name is specified, then we only want to dump that one db.
                if (empty($this->databaseName) || ($this->databaseName && $database->getName() == $this->databaseName)) {

                    $outFile = $this->getMappedFile($dataModel->getName());

                    $this->log("Dumping data to XML for database: " . $database->getName());
                    $this->log("Writing to XML file: " . $outFile->getName());

                    try {
                        $this->conn = $dataModel->getGeneratorConfig()->getBuildPDO($database->getName());

                        $doc = $this->createXMLDoc($database);
                        $doc->save($outFile->getAbsolutePath());
                    } catch (SQLException $se) {
                        $this->log("SQLException while connecting to DB: " . $se->getMessage(), Project::MSG_ERR);
                        throw new BuildException($se);
                    }
                } // if databaseName && database->getName == databaseName
            } // foreach database
        } // foreach datamodel
    }
976333
def validate(self):
        """"""
        # Literals representing boolean values or None are correctly representable and supported.
        if self.value is None or self.value is True or self.value is False:
            return

        # Literal safe strings are correctly representable and supported.
        if isinstance(self.value, six.string_types):
            validate_safe_string(self.value)
            return

        # Literal ints are correctly representable and supported.
        if isinstance(self.value, int):
            return

        # Literal empty lists, and non-empty lists of safe strings, are
        # correctly representable and supported.
        if isinstance(self.value, list):
            if len(self.value) > 0:
                for x in self.value:
                    validate_safe_string(x)
            return

        raise GraphQLCompilationError(u'Cannot represent literal: {}'.format(self.value))
270225
def _is_valid_input(self, inpt, metadata, array):
        
        # pylint: disable=too-many-branches,no-self-use
        # Please redesign, and move to utility module
        syntax = metadata.get_syntax()

        # First check if this is a required data element
        if metadata.is_required and not inpt:
            return False

        valid = True  # Innocent until proven guilty
        # Recursively run through all the elements of an array
        if array:
            if len(inpt) < metadata.get_minimum_elements():
                valid = False
            elif len(inpt) > metadata.get_maximum_elements():
                valid = False
            else:
                for element in inpt:
                    valid = (valid and self._is_valid_input(element, metadata, False))

        # Run through all the possible syntax types
        elif syntax == 'ID':
            valid = self._is_valid_id(inpt)
        elif syntax == 'TYPE':
            valid = self._is_valid_type(inpt)
        elif syntax == 'BOOLEAN':
            valid = self._is_valid_boolean(inpt)
        elif syntax == 'STRING':
            valid = self._is_valid_string(inpt, metadata)
        elif syntax == 'INTEGER':
            valid = self._is_valid_integer(inpt, metadata)
        elif syntax == 'DECIMAL':
            valid = self._is_valid_decimal(inpt, metadata)
        elif syntax == 'DATETIME':
            valid = self._is_valid_date_time(inpt, metadata)
        elif syntax == 'DURATION':
            valid = self._is_valid_duration(inpt, metadata)
        elif syntax == 'CARDINAL':
            valid = self._is_valid_cardinal(inpt, metadata)
        elif syntax == 'INTEGER':
            valid = self._is_valid_integer(inpt, metadata)
        elif syntax == 'DECIMAL':
            valid = self._is_valid_decimal(inpt, metadata)
        else:
            raise errors.OperationFailed('no validation function available for ' + syntax)

        return valid