Set Data validation rules

@param    PHPExcel_Cell_DataValidation    $pDataValidation
@return    PHPExcel_Cell
@throws    PHPExcel_Exception
161681
public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation = null)
    {
        if (!isset($this->parent)) {
            throw new PHPExcel_Exception('Cannot set data validation for cell that is not bound to a worksheet');
        }

        $this->getWorksheet()->setDataValidation($this->getCoordinate(), $pDataValidation);

        return $this->notifyCacheController();
    }
1186004
protected function validate($data)
    {
        $data = $this->validateSegment($data);
        if (! $data) {
            return $data;
        }

        $this->saveInternalEncoding();
        if (! $this->isValidHostLength($data)) {
            $this->restoreInternalEncoding();
            throw new RuntimeException('Invalid hostname, check its length');
        }

        if (! $this->isValidHostPattern($data)) {
            $this->restoreInternalEncoding();
            throw new RuntimeException('Invalid host label, check its content');
        }

        if (! $this->isValidHostLabels($data)) {
            $this->restoreInternalEncoding();
            throw new RuntimeException('Invalid host label counts, check its count');
        }

        $data = $this->sanitizeValue($data);
        $data = explode(
            $this->delimiter,
            $this->punycode->decode(implode($this->delimiter, $data))
        );
        $this->restoreInternalEncoding();

        return $data;
    }
1264856
public function settingsValidate(Event $event, $data, Validator $validator)
    {
        if (isset($data['password_min_length'])) {
            $validator
                ->add('password_min_length', 'validNumber', [
                    'rule' => ['naturalNumber', false], // false: exclude zero
                    'message' => __d('user', 'Invalid password min-length.')
                ]);
        }

        $validator
            ->requirePresence('message_welcome_subject')
            ->notEmpty('message_welcome_subject', __d('user', 'This field cannot be empty.'))

            ->requirePresence('message_welcome_body')
            ->notEmpty('message_welcome_body', __d('user', 'This field cannot be empty.'))

            ->requirePresence('message_password_recovery_subject')
            ->notEmpty('message_password_recovery_body', __d('user', 'This field cannot be empty.'))

            ->requirePresence('message_cancel_request_subject')
            ->notEmpty('message_cancel_request_body', __d('user', 'This field cannot be empty.'));

        if ($data['message_activation']) {
            $validator
                ->requirePresence('message_activation_subject')
                ->notEmpty('message_activation_body', __d('user', 'This field cannot be empty.'));
        }

        if ($data['message_blocked']) {
            $validator
                ->requirePresence('message_blocked_subject')
                ->notEmpty('message_blocked_body', __d('user', 'This field cannot be empty.'));
        }

        if ($data['message_canceled']) {
            $validator
                ->requirePresence('message_canceled_subject')
                ->notEmpty('message_canceled_body', __d('user', 'This field cannot be empty.'));
        }
    }
797700
public function validateValidatorConfiguration($validatorConfiguration)
    {
        $validationErrors = array();

        foreach ($validatorConfiguration as $validatorIdentifier => $parameters) {
            switch ($validatorIdentifier) {
                case 'FileSizeValidator':
                    if (!array_key_exists('maxFileSize', $parameters)) {
                        $validationErrors[] = new ValidationError(
                            'Validator %validator% expects parameter %parameter% to be set.',
                            null,
                            array(
                                '%validator%' => $validatorIdentifier,
                                '%parameter%' => 'maxFileSize',
                            ),
                            "[$validatorIdentifier][maxFileSize]"
                        );
                        break;
                    }
                    if (!is_int($parameters['maxFileSize']) && $parameters['maxFileSize'] !== null) {
                        $validationErrors[] = new ValidationError(
                            'Validator %validator% expects parameter %parameter% to be of %type%.',
                            null,
                            array(
                                '%validator%' => $validatorIdentifier,
                                '%parameter%' => 'maxFileSize',
                                '%type%' => 'integer',
                                "[$validatorIdentifier][maxFileSize]",
                            )
                        );
                    }
                    break;
                default:
                    $validationErrors[] = new ValidationError(
                        "Validator '%validator%' is unknown",
                        null,
                        array(
                            '%validator%' => $validatorIdentifier,
                        ),
                        "[$validatorIdentifier]"
                    );
            }
        }

        return $validationErrors;
    }
1143572
public function consistentDataValdiateRule ($callback, $validate_rule = []) {
		return function () use ($callback, $validate_rule) {
			$consistent_validate_rule = [];

			foreach ($callback() as $id => $value) {
				$consistent_validate_rule[$id] = [
					'force_validate'	=> false,
					'force_value'		=> false,
					'value'	=> $value,
					['===', static::ReadSuidSession($id), 'raise_exception', 'message' => 'トランザクション中固定値がマッチしません。target:{:title} input:{:value}, session:{:operand:0}'],
				];
			}

			return $consistent_validate_rule + $validate_rule;
		};
	}
1264921
protected function validate(array $data)
    {
        $validator = $this->validator->make(
            $data,
            [
                'username' => 'min:6|max:60',
                'password' => 'min:6|max:255',
                'email' => 'email|max:100'
            ]
        );

        if ($validator->fails()) {
            $message = sprintf(
                'Invalid user credentials. %s',
                implode(' ', $validator->errors()->all())
            );
            throw new UserException($message);
        }
    }
507146
public function validate(array $constraints, $data, $prettyName = 'This value')
    {
        if (gettype($data) == 'array') {
            $this->validateSequentialArray($data, $prettyName);
        } else {
            $message = $constraints['message'] ?? '%s must be a sequential array';
            throw new DataValidationException(sprintf($message, $prettyName));
        }

        parent::validate($constraints, $data, $prettyName);
    }
940794
private function validateData($rules, $data) {
		$errors = [];
		foreach ($rules as $field => $rule) {
			$valid = $this->validateField($field, $data, $rule);
			if ($valid !== true) {
				$errors[ $field ] = $valid;
			}
		}
		if (!empty($errors)) {
			throw new ValidateException($errors);
		}

		return true;
	}
217333
public function validate($data, $throwException = true)
    {
        if (empty($rules = $this->getRules())) {
            return true;
        } else {
            $validator = Validator::make($data, $rules, $this->validationMessages);

            if ($validator->fails()) {
                $this->errors($validator->errors()->getMessages());
                if ($throwException) {
                    $errorString = DataFormatter::validationErrorsToString($this->getErrors());
                    throw new BadRequestException('Invalid data supplied.' . $errorString, null, null, $this->getErrors());
                } else {
                    return false;
                }
            } else {
                return true;
            }
        }
    }
365749
protected function _setValidator($validator)
    {
        if (!is_null($validator) && !($validator instanceof ValidatorInterface)) {
            throw $this->_createInvalidArgumentException($this->__('Invalid validator'), null, null, $validator);
        }

        $this->validator = $validator;
    }
1348804
public function validate(array $formData)
    {
        $this->validation = $this->validator->make($formData, $this->getValidationRules());

        if($this->validation->fails())
            throw new FormValidatorException('Validation failed', $this->getValidationErrors());
        return true;
    }
700700
public function validateResponseData($data)
    {
        if (!isset($data->status)) {
            throw EventValidationResponseCorruptDataException::eventApiResponseCorrupt($data);
        } elseif (isset($data->errors)) {
            throw EventValidationResponseErrorException::eventApiResponseError($data->errors[0]);
        }
    }
1108637
public function hasDataValidation()
	{
		if (!isset($this->_parent)) {
			throw new PHPExcel_Exception('Cannot check for data validation when cell is not bound to a worksheet');
		}

		return $this->getWorksheet()->dataValidationExists($this->getCoordinate());
	}
1238496
public List<ValidationData> saveAll(List<ValidationData> pDatas) {
        pDatas.forEach(this::save);
        return pDatas;
    }
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;
    }
1148711
public function getDataValidation($pCellCoordinate = 'A1')
    {
        // return data validation if we already have one
        if (isset($this->_dataValidationCollection[$pCellCoordinate])) {
            return $this->_dataValidationCollection[$pCellCoordinate];
        }

        // else create data validation
        $this->_dataValidationCollection[$pCellCoordinate] = new PHPExcel_Cell_DataValidation();
        return $this->_dataValidationCollection[$pCellCoordinate];
    }
950357
private function _writeDataValidations(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
	{
		// Datavalidation collection
		$dataValidationCollection = $pSheet->getDataValidationCollection();

		// Write data validations?
		if (!empty($dataValidationCollection)) {
			$objWriter->startElement('dataValidations');
			$objWriter->writeAttribute('count', count($dataValidationCollection));

			foreach ($dataValidationCollection as $coordinate => $dv) {
				$objWriter->startElement('dataValidation');

				if ($dv->getType() != '') {
					$objWriter->writeAttribute('type', $dv->getType());
				}

				if ($dv->getErrorStyle() != '') {
					$objWriter->writeAttribute('errorStyle', $dv->getErrorStyle());
				}

				if ($dv->getOperator() != '') {
					$objWriter->writeAttribute('operator', $dv->getOperator());
				}

				$objWriter->writeAttribute('allowBlank',		($dv->getAllowBlank()		? '1'  : '0'));
				$objWriter->writeAttribute('showDropDown',		(!$dv->getShowDropDown()	? '1'  : '0'));
				$objWriter->writeAttribute('showInputMessage',	($dv->getShowInputMessage()	? '1'  : '0'));
				$objWriter->writeAttribute('showErrorMessage',	($dv->getShowErrorMessage()	? '1'  : '0'));

				if ($dv->getErrorTitle() !== '') {
					$objWriter->writeAttribute('errorTitle', $dv->getErrorTitle());
				}
				if ($dv->getError() !== '') {
					$objWriter->writeAttribute('error', $dv->getError());
				}
				if ($dv->getPromptTitle() !== '') {
					$objWriter->writeAttribute('promptTitle', $dv->getPromptTitle());
				}
				if ($dv->getPrompt() !== '') {
					$objWriter->writeAttribute('prompt', $dv->getPrompt());
				}

				$objWriter->writeAttribute('sqref', $coordinate);

				if ($dv->getFormula1() !== '') {
					$objWriter->writeElement('formula1', $dv->getFormula1());
				}
				if ($dv->getFormula2() !== '') {
					$objWriter->writeElement('formula2', $dv->getFormula2());
				}

				$objWriter->endElement();
			}

			$objWriter->endElement();
		}
	}