Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary

@throws PHPExcel_Exception
966190
protected function adjustForExistingOnlyRange()
    {
        if ($this->onlyExistingCells) {
            while ((!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->startRow)) &&
                ($this->startRow <= $this->endRow)) {
                ++$this->startRow;
            }
            if ($this->startRow > $this->endRow) {
                throw new PHPExcel_Exception('No cells exist within the specified range');
            }
            while ((!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->endRow)) &&
                ($this->endRow >= $this->startRow)) {
                --$this->endRow;
            }
            if ($this->endRow < $this->startRow) {
                throw new PHPExcel_Exception('No cells exist within the specified range');
            }
        }
    }
147774
private static function validExcelObj($excelObj=NULL)
    {
        if (is_object($excelObj)) {

            return $excelObj;
        } 
        elseif (is_object(self::$_objSpreadsheet)) {

            return self::$_objSpreadsheet;
        } 
        else {
            
            throw new Exception("Invalid or empty PhpSpreadsheet Object", 400);
        }
    }
751747
protected function validateLimit(): void
    {
        $limit = $this->getArrayValue($this->joryArray, ['lmt', 'limit']);

        // No limit set, that's ok. return.
        if ($limit === null) {
            return;
        }

        if (! is_int($limit)) {
            throw new JoryException('The limit parameter should be an integer value. (Location: '.$this->address.'limit)');
        }
    }
1336306
protected void validateDataWhenConstruct() throws WriteExcelException {
        if (this.rowNumReserved > EXCEL_ROW_RESERVED_MOST) {
            throw new WriteExcelException(String.format("预留行数不得超过最大值%d", EXCEL_ROW_RESERVED_MOST));
        }
        if (this.limit > 0) {
            if (XLSX == this.excelType && this.allowMaxRows > XLSX_ROW_MOST) {
                throw new WriteExcelException(String.format("每页行数不得超过最大值%d", XLSX_ROW_MOST));
            }
            if (XLS == this.excelType && this.allowMaxRows > XLS_ROW_MOST) {
                throw new WriteExcelException(String.format("每页行数不得超过最大值%d", XLS_ROW_MOST));
            }
        }
    }
170162
@Override
    public void validate() throws Exception {
        super.validate();
        this.parse();
        Assert.assertTrue("The upper date should be after the initial date",
                this.upper.after(this.lower));
    }
1371479
public function validateCall(): void
    {

        if (! in_array($this->method, ['get', 'post', 'put', 'patch', 'delete']))
            throw new Exception('Invalid HTTP method used');

        if (trim($this->endpoint) === '')
            throw new Exception('Empty endpoint used');

        // Enfore a version specification unless this is a 'meta' call.
        if (trim($this->version) === '' && ! (in_array('meta', $this->tags())))
            throw new Exception('Version is empty');
    }
1183631
function (startCell, endCell, callback) {
      var result = {
        index: [], // list of cell index: A1, A2, A3
        value: []  // list of cell value
      };

      var cols = {
        start: 0,
        end: 0
      };

      if (endCell.col >= startCell.col) {
        cols = {
          start: startCell.col,
          end: endCell.col
        };
      } else {
        cols = {
          start: endCell.col,
          end: startCell.col
        };
      }

      var rows = {
        start: 0,
        end: 0
      };

      if (endCell.row >= startCell.row) {
        rows = {
          start: startCell.row,
          end: endCell.row
        };
      } else {
        rows = {
          start: endCell.row,
          end: startCell.row
        };
      }

      for (var column = cols.start; column <= cols.end; column++) {
        for (var row = rows.start; row <= rows.end; row++) {
          var cellIndex = instance.utils.toChar(column) + (row + 1),
              cellValue = instance.helper.cellValue.call(this, cellIndex);

          result.index.push(cellIndex);
          result.value.push(cellValue);
        }
      }

      if (instance.utils.isFunction(callback)) {
        return callback.apply(callback, [result]);
      } else {
        return result;
      }
    }
1084101
protected function validate_after_order() {
        $nodearray = $this->nodes;
        foreach ($this->nodes as $node) {
            $after = $node->after;
            if (!empty($after)) {
                if (empty($nodearray[$after])) {
                    throw new \coding_exception('node {$node->name} specified contains invalid \'after\' property');
                } else {
                    // Valid node found.
                    $afternode = $nodearray[$after];
                    $beforecontent = $node->content;
                    $aftercontent = $afternode->content;

                    if ((empty($beforecontent) && !empty($aftercontent)) || (!empty($beforecontent) && empty($aftercontent))) {
                        // Only node with content are allowed after content nodes. Same goes for no content nodes.
                        throw new \coding_exception('node {$node->name} specified contains invalid \'after\' property');
                    }
                }
            }
        }
    }
124235
public function bindValue(PHPExcel_Cell $cell, $value = null)
    {
        // sanitize UTF-8 strings
        if (is_string($value)) {
            $value = PHPExcel_Shared_String::SanitizeUTF8($value);
        }

        // Set value explicit
        $cell->setValueExplicit( $value, self::dataTypeForValue($value) );

        // Done!
        return TRUE;
    }
967198
protected function validateSorts(): void
    {
        $sorts = $this->getArrayValue($this->joryArray, ['srt', 'sorts']);

        // No sorts set, that's ok. return.
        if (! $sorts) {
            return;
        }

        if (! is_array($sorts)) {
            throw new JoryException('The sorts parameter should be an array. (Location: '.$this->address.'sorts)');
        }

        foreach ($sorts as $sort) {
            if (! is_string($sort)) {
                throw new JoryException('A sort item must be a string. (Location: '.$this->address.'sorts)');
            }
        }
    }
655506
public function mergeCellRange($startRow, $startColumn, $endRow, $endColumn)
    {
        list($startRow, $startColumn, $endRow, $endColumn)
                = PHPRtfLite_Table::getValidCellRange($startRow, $startColumn, $endRow, $endColumn);

        if ($startRow == $endRow && $startColumn == $endColumn) {
            return;
        }

        if (!$this->checkIfCellExists($endRow, $endColumn)) {
            return;
        }

        for ($j = $startRow; $j <= $endRow; $j++) {
            $start = $startColumn;
            $cell = $this->getCell($j, $start);

            while ($cell->isHorizontalMerged()) {
                $start--;
                $cell = $this->getCell($j, $start);
            }

            $end = $endColumn;

            $cell = $this->getCell($j, $end);
            while ($cell->isHorizontalMerged()) {
                $end++;
                $cell = $this->getCell($j, $end + 1);
            }

            $width = 0;

            for ($i = $start; $i <= $end; $i++) {
                $cell = $this->getCell($j, $i);
                if ($j == $startRow) {
                    $cell->setVerticalMergeStart();
                }
                else {
                    $cell->setVerticalMerged();
                }

                $width += $cell->getWidth();
                if ($i != $start) {
                    $cell->setHorizontalMerged();
                }
            }

            $this->getCell($j, $start)->setWidth($width);
        }
    }
1370955
def checkQueryRange(self, start, end):
        
        condition = (
            (start < 0 or end > self.getLength()) or
            start > end or start == end)
        if condition:
            raise exceptions.ReferenceRangeErrorException(
                self.getId(), start, end)
388104
public function validate() {

		if ($this->getRate() === null) {
			throw new ValidationException("'rate' can't be null", 'rate', $this);
		}
		if ($this->getTitle() === null) {
			throw new ValidationException("'title' can't be null", 'title', $this);
		}
	}
681525
protected function validate_data() {
        parent::validate_data();
        if (!isset($this->other['searchterm'])) {
            throw new \coding_exception('The \'searchterm\' value must be set in other.');
        }

        if ($this->contextlevel != CONTEXT_COURSE) {
            throw new \coding_exception('Context level must be CONTEXT_COURSE.');
        }
    }
1184575
public function getDataValidation()
	{
		if (!isset($this->_parent)) {
			throw new PHPExcel_Exception('Cannot get data validation for cell that is not bound to a worksheet');
		}

		return $this->getWorksheet()->getDataValidation($this->getCoordinate());
	}
435419
public function validate(): void
    {
        $required = [
            'app_root',
            'app_name',
            'default_filesystem',
            'environment',
            'default_branch',
            'default_database_adapter',
            'default_database_importexport_adapter',
            'default_dir_mode',
            'default_file_mode',
            'platform',
            'relative_document_root',
            'repo_url',
        ];
        $missingRequired = [];
        foreach ($required as $name) {
            if (empty($this->config[$name])) {
                $missingRequired[] = $name;
            }
        }
        if ($missingRequired) {
            throw new Exception\RuntimeException(
                'Missing required values for top level configuration key(s): "' . implode('", "', $missingRequired)
                . '"'
            );
        }

        if (!in_array(
            $this->config['file_layout'],
            [
                FileLayoutInterface::STRATEGY_BLUE_GREEN,
                FileLayoutInterface::STRATEGY_DEFAULT
            ]
        )) {
            throw new Exception\DomainException("Invalid file layout \"{$this->config['file_layout']}\".");
        }

        $this->buildConfig->validate();
        $this->deployConfig->validate();
        $this->snapshotConfig->validate();
        $this->skeletonConfig->validate();
    }
177101
protected final function validate_before_trigger() {
        global $DB, $CFG;

        if (empty($this->data['crud'])) {
            throw new \coding_exception('crud must be specified in init() method of each method');
        }
        if (!isset($this->data['edulevel'])) {
            throw new \coding_exception('edulevel must be specified in init() method of each method');
        }
        if (!empty($this->data['objectid']) and empty($this->data['objecttable'])) {
            throw new \coding_exception('objecttable must be specified in init() method if objectid present');
        }

        if ($CFG->debugdeveloper) {
            // Ideally these should be coding exceptions, but we need to skip these for performance reasons
            // on production servers.

            if (!in_array($this->data['crud'], array('c', 'r', 'u', 'd'), true)) {
                debugging("Invalid event crud value specified.", DEBUG_DEVELOPER);
            }
            if (!in_array($this->data['edulevel'], array(self::LEVEL_OTHER, self::LEVEL_TEACHING, self::LEVEL_PARTICIPATING))) {
                // Bitwise combination of levels is not allowed at this stage.
                debugging('Event property edulevel must a constant value, see event_base::LEVEL_*', DEBUG_DEVELOPER);
            }
            if (self::$fields !== array_keys($this->data)) {
                debugging('Number of event data fields must not be changed in event classes', DEBUG_DEVELOPER);
            }
            $encoded = json_encode($this->data['other']);
            // The comparison here is not set to strict as whole float numbers will be converted to integers through JSON encoding /
            // decoding and send an unwanted debugging message.
            if ($encoded === false or $this->data['other'] != json_decode($encoded, true)) {
                debugging('other event data must be compatible with json encoding', DEBUG_DEVELOPER);
            }
            if ($this->data['userid'] and !is_number($this->data['userid'])) {
                debugging('Event property userid must be a number', DEBUG_DEVELOPER);
            }
            if ($this->data['courseid'] and !is_number($this->data['courseid'])) {
                debugging('Event property courseid must be a number', DEBUG_DEVELOPER);
            }
            if ($this->data['objectid'] and !is_number($this->data['objectid'])) {
                debugging('Event property objectid must be a number', DEBUG_DEVELOPER);
            }
            if ($this->data['relateduserid'] and !is_number($this->data['relateduserid'])) {
                debugging('Event property relateduserid must be a number', DEBUG_DEVELOPER);
            }
            if ($this->data['objecttable']) {
                if (!$DB->get_manager()->table_exists($this->data['objecttable'])) {
                    debugging('Unknown table specified in objecttable field', DEBUG_DEVELOPER);
                }
                if (!isset($this->data['objectid'])) {
                    debugging('Event property objectid must be set when objecttable is defined', DEBUG_DEVELOPER);
                }
            }
        }
    }