Validates the time splitting method ranges.

@throws \coding_exception
@return void
977257
protected function validate_ranges() {
        foreach ($this->ranges as $key => $range) {
            if (!isset($this->ranges[$key]['start']) || !isset($this->ranges[$key]['end']) ||
                    !isset($this->ranges[$key]['time'])) {
                throw new \coding_exception($this->get_id() . ' time splitting method "' . $key .
                    '" range is not fully defined. We need a start timestamp and an end timestamp.');
            }
        }
    }
918506
protected function isEndTimeValid()
    {
        $this->valid_range_end->setYear(self::$date_year);
        $this->valid_range_end->setMonth(self::$date_month);
        $this->valid_range_end->setDay(self::$date_day);
        $this->valid_range_end->setTZById('UTC');

        return SwatDate::compare($this->value, $this->valid_range_end, true) <=
            0;
    }
566854
public function validateTimestamps()
    {
        if ($this->encrypted) {
            $document = $this->decryptedDocument;
        } else {
            $document = $this->document;
        }

        $timestampNodes = $document->getElementsByTagName('Conditions');
        for ($i = 0; $i < $timestampNodes->length; $i++) {
            $nbAttribute = $timestampNodes->item($i)->attributes->getNamedItem("NotBefore");
            $naAttribute = $timestampNodes->item($i)->attributes->getNamedItem("NotOnOrAfter");
            if ($nbAttribute && OneLogin_SAML2_Utils::parseSAML2Time($nbAttribute->textContent) > time() + OneLogin_Saml2_Constants::ALLOWED_CLOCK_DRIFT) {
                throw new OneLogin_Saml2_ValidationError(
                    'Could not validate timestamp: not yet valid. Check system clock.',
                    OneLogin_Saml2_ValidationError::ASSERTION_TOO_EARLY
                );
            }
            if ($naAttribute && OneLogin_SAML2_Utils::parseSAML2Time($naAttribute->textContent) + OneLogin_Saml2_Constants::ALLOWED_CLOCK_DRIFT <= time()) {
                throw new OneLogin_Saml2_ValidationError(
                    'Could not validate timestamp: expired. Check system clock.',
                    OneLogin_Saml2_ValidationError::ASSERTION_EXPIRED
                );
            }
        }
        return true;
    }
41089
def validate_time_range(form, field):
    

    string = field.data
    try:
        begin, end = string.split('-')
        begin = begin.strip()
        end = end.strip()
        begin_hours, begin_min = begin.split(':')
        end_hours, end_min = end.split(':')
        assert 0 <= int(begin_hours) <= 23
        assert 0 <= int(end_hours) <= 23
        assert 0 <= int(begin_min) <= 59
        assert 0 <= int(end_min) <= 59
        assert begin_hours <= end_hours
        if begin_hours == end_hours:
            assert begin_min < end_min
    except (ValueError, AssertionError):
        raise ValidationError('Make sure the time is in correct format: "hh:mm - hh:mm"')
613883
protected function validateRun()
    {
        $status = $this->process->getExitCode();
        $error  = $this->process->getErrorOutput();

        if ($status !== 0 and $error !== '') {
            throw new \RuntimeException(
                sprintf(
                    "The exit status code %s says something went wrong:\n stderr: %s\n stdout: %s\ncommand: %s.",
                    $status,
                    $error,
                    $this->process->getOutput(),
                    $this->command
                )
            );
        }
    }
192085
protected function validate_data() {
        if ($this->other === null) {
            throw new \coding_exception('The \'competencyid\' and \'planid\' values must be set.');
        }

        if (!isset($this->other['competencyid'])) {
            throw new \coding_exception('The \'competencyid\' value must be set.');
        }

        if (!isset($this->other['planid'])) {
            throw new \coding_exception('The \'planid\' value must be set.');
        }
    }
678323
public function onBeforeWrite()
    {
        parent::onBeforeWrite();

        $debug = false;
        if (CalendarConfig::subpackage_enabled('debug')) {
            $debug = true;
        }
        //echo "executing onbeforewrite \n";

        //only allowing to run this once:
        if ($this->hasWritten) {
            return false;
        }
        $this->hasWritten = true;
        //echo "this should only execute once \n";


        //Convert to allday event if the entered time is 00:00
        //(i.e. this field has been left blank)
        //This only happens if allday events are enabled
        //NOTE: Currently it seems to me as if there should be no need to disable allday events
        if (CalendarConfig::subpackage_setting('events', 'enable_allday_events')) {
            //This only happens on first save to correct for the rare cases that someone might
            //actually want to add an event like this
            if (!$this->ID) {
                if (date("H:i", strtotime($this->StartDateTime))  == '00:00') {
                    $this->AllDay = true;
                    if ($debug) {
                        $this->debugLog('Converted to allday event as the entered time was 00:00');
                    }
                }
            }
        }

        //If the timeframetype is duration - set end date based on duration
        if ($this->TimeFrameType == 'Duration') {
            $formatDate = $this->calcEndDateTimeBasedOnDuration();
            //only write the end date if a duration has actually been entered
            //If not, leave the end date blank for now, and it'll be taken care later in this method
            if ($this->StartDateTime != $formatDate) {
                $this->EndDateTime = $formatDate;
                if ($debug) {
                    $this->debugLog('Time frame type: Duration: Set end date');
                }
            } else {
                //setting the end date/time to null, as it has automatically been set via javascript
                $this->EndDateTime = null;
                if ($debug) {
                    $this->debugLog('Time frame type: Duration: setting the end date/time to null, as it has automatically been set via javascript');
                }
            }
        } else {
            //reset duration
            $this->Duration = '';
            if ($debug) {
                $this->debugLog('reset duration');
            }
        }

        //Sanity checks:

        //1. We always need an end date/time - if no end date is set, set end date 1 hour after start date
        //This won't happen if leaving end date/time empty is allowed through the config
        //This should not happen to single day allday events as these are supposed to have start and end date
        //set to the same date via the js in the edit form
        if (CalendarConfig::subpackage_setting('events', 'force_end')) {
            if (!$this->EndDateTime) {
                $this->EndDateTime = date("Y-m-d H:i:s", strtotime($this->StartDateTime) + 3600);
                if ($debug) {
                    $this->debugLog('Sanity check 1: Setting end date');
                }
            }
        }

        //2. We can't have negative dates
        //If this happens for some reason, we make the event an allday event, and set start date = end date
        //Should only be triggered, if EndDateTime is set

        if (isset($this->EndDateTime)) {
            if (strtotime($this->EndDateTime) < strtotime($this->StartDateTime)) {
                $this->EndDateTime = $this->StartDateTime;
                $this->AllDay = true;
                $msg = "Sanity check 2: Setting end date = start date and setting all day \n"
                . "as {$this->EndDateTime} was lower than {$this->StartDateTime} \n"
                . strtotime($this->EndDateTime) . " vs " . strtotime($this->StartDateTime);
                if ($debug) {
                    $this->debugLog($msg);
                }
            }
        }

        //3. If end dates are not enforced, and no end date has been set, set the NoEnd attribute
        //Equally, if the Noend attribute has been set  via a checkbox, we reset EndDateTime and Duration
        if (!CalendarConfig::subpackage_setting('events', 'force_end')) {
            if (isset($this->EndDateTime)) {
                if ($this->NoEnd) {
                    $this->Duration = null;
                    $this->EndDateTime = null;
                    if ($debug) {
                        $this->debugLog('Sanity check 3: as the event has the noend setting, setting duration and enddatetime to null');
                    }
                }
            } else {
                $this->NoEnd = true;
                if ($debug) {
                    $this->debugLog('Sanity check 3: as end date/time has not been set, setting NoEnd to true');
                }
            }
        }

        //4. All day events can't have open ends
        //so if and event both has the allday attribute and the noend attribute,
        //noend is enforced over allday
        if ($this->AllDay && $this->NoEnd) {
            $this->AllDay = false;
            if ($debug) {
                $this->debugLog('Sanity check 4: as both allday and noend have been set, noend wins');
            }
        }
    }
1338792
private static function validate() {
	if (self::is_active() == false) {
		$exception = bootstrap::get_library('exception');
		throw new $exception('inactive session');
	}
	
	if (empty($_SESSION['_session_type']) || empty($_SESSION['_session_last_active'])) {
		return false;
	}
	
	// throw away expired (replaced) sessions
	if (!empty($_SESSION['_session_expire_at']) && $_SESSION['_session_expire_at'] < time()) {
		return false;
	}
	
	// last_active short enough ago
	$type_duration = self::$type_durations[ $_SESSION['_session_type'] ];
	$active_enough = ($_SESSION['_session_last_active'] > (time() - $type_duration));
	if ($active_enough == false) {
		return false;
	}
	
	return true;
}
465424
protected function validate_data() {
        parent::validate_data();

        if (!isset($this->other['discussionid'])) {
            throw new \coding_exception('The \'discussionid\' value must be set in other.');
        }

        if (!isset($this->other['forumid'])) {
            throw new \coding_exception('The \'forumid\' value must be set in other.');
        }

        if (!isset($this->other['forumtype'])) {
            throw new \coding_exception('The \'forumtype\' value must be set in other.');
        }

        if ($this->contextlevel != CONTEXT_MODULE) {
            throw new \coding_exception('Context level must be CONTEXT_MODULE.');
        }
    }
517852
public function validateOrFail()
    {
        // Validate data
        $passed = $this->validate();

        // If validation failed,
        // we'll throw an exception
        if (! $passed) {
            throw new ValidationException($this->validator, $this->getErrorCodes());
        }

        return true;
    }
68176
@Override
    public void validate() throws Exception {
        super.validate();
        this.parse();
        Assert.assertTrue(
                String.format(
                        "Lower bound %d should be less than upper bound %d",
                        lower,
                        upper),
                lower <= upper);
        Assert.assertFalse(
                "The range is empty",
                !this.includeLower
                    && !this.includeUpper
                    && (this.upper - this.lower) <= 1);
        Assert.assertFalse(
                "The range is empty",
                !(this.includeLower && this.includeUpper)
                    && (this.upper - this.lower) < 1);
    }
24103
public void validate() {
    if (interval == null || interval.isEmpty()) {
      throw new IllegalArgumentException("Missing or empty interval");
    }
    DateTime.parseDuration(interval);
    
    if (aggregator == null || aggregator.isEmpty()) {
      throw new IllegalArgumentException("Missing or empty aggregator");
    }
    try {
      Aggregators.get(aggregator.toLowerCase());
    } catch (final NoSuchElementException e) {
      throw new IllegalArgumentException("Invalid aggregator");
    }
    
    if (fill_policy != null) {
      fill_policy.validate();
    }
  }
577860
protected function validateRanges()
    {
        if (!$this->isStartDateValid()) {
            $message = sprintf(
                Swat::_(
                    'The date you have entered is invalid. ' .
                        'It must be on or after %s.'
                ),
                $this->getFormattedDate($this->valid_range_start)
            );

            $this->addMessage(new SwatMessage($message, 'error'));
        } elseif (!$this->isEndDateValid()) {
            $message = sprintf(
                Swat::_(
                    'The date you have entered is invalid. ' .
                        'It must be before %s.'
                ),
                $this->getFormattedDate($this->valid_range_end)
            );

            $this->addMessage(new SwatMessage($message, 'error'));
        }
    }
1349052
private function validateDateTime($value): void
    {
        try {
            if(
                is_a($value, DateTime::class) ||
                is_null($value) ||
                $value === 'now'
            ) {
                // Expected and valid values, no need to attempt conversion
            } else {
                if($this->isUnixTimestamp($value)) {
                    // Try making a DateTime with a UNIX Timestamp from a string
                    DateTime::createFromFormat("U.u", $this->unixTimestampAsUuFormat($value));
                } else {
                    // Try making a DateTime with whatever remains
                    new DateTime($value);
                }
            }
        } catch (Exception $e) {
            throw new TypeValidationException('Attempted to pass non-date[time] value to date[time] type');
        }
    }
694658
private function validateGreaterThan(): bool
    {
        if ($this->options['min'] !== null) {
            if ($this->options['inclusive'] === false && $this->value <= $this->options['min']) {
                $this->setError(self::VALIDATOR_ERROR_NUMBER_MUST_BE_HIGHER_THAN_MIN);
                return false;
            }

            if ($this->value < $this->options['min']) {
                $this->setError(self::VALIDATOR_ERROR_NUMBER_MUST_BE_HIGHER_OR_EQUAL_TO_MIN);
                return false;
            }
        }
        return true;
    }
1262864
public function validate() : void
    {
        if (null === $this->is_valid) {
            if (null === $this->user_value && null !== $this->default_value) {
                // There is a preset value, and its not being changed
                $this->is_valid = true;
            } elseif (null != $this->validator && false != $this->validator) {
                if ('' === $this->user_value && false === $this->required) {
                    $this->is_valid = true;
                    return;
                } elseif ('' === $this->user_value && true === $this->required) {
                    $this->is_valid = false;
                    return;
                }
                try {
                    $validator = $this->validator;
                    $result = $validator::quickValidate($this->user_value, $this->constraints);
                    $this->user_value = $result;
                    $this->is_valid = true;
                } catch (InvalidInputException $e) {
                    $this->user_value = null;
                    $this->is_valid = false;
                    $this->error = $e->getMessage();
                }

            } else {
                // This field does not get validated
                $this->is_valid = true;
            }
        }
        // Check if the input is different from the default value
        if ($this->is_valid && null !== $this->user_value) {
            $this->is_changed = ($this->default_value != $this->user_value);
        }
    }
466903
public function inValidRange(): bool
    {
        return $this->minimum_julian_day >= $this->calendar->jdStart() && $this->maximum_julian_day <= $this->calendar->jdEnd();
    }