Validates this Cron instance by validating its cron expression.

@return this Cron instance
@throws IllegalArgumentException if the cron expression is invalid
193565
public Cron validate() {
        for (final Map.Entry<CronFieldName, CronField> field : retrieveFieldsAsMap().entrySet()) {
            final CronFieldName fieldName = field.getKey();
            field.getValue().getExpression().accept(
                    new ValidationFieldExpressionVisitor(getCronDefinition().getFieldDefinition(fieldName).getConstraints(), cronDefinition.isStrictRanges())
            );
        }
        for (final CronConstraint constraint : getCronDefinition().getCronConstraints()) {
            if (!constraint.validate(this)) {
                throw new IllegalArgumentException(String.format("Invalid cron expression: %s. %s", asString(), constraint.getDescription()));
            }
        }
        return this;
    }
1240710
public function validateDate()
    {
        if (
            ($from = $this->getAvailableFrom()) &&
            ($till = $this->getAvailableTill()) &&
            $from->InPast() &&
            $till->InFuture()
        ) {
            return true;
        }

        return false;
    }
494002
public function validateCronExpression($cronExpression)
    {
        try {
            $schedule = Mage::getModel('cron/schedule');
            /* @var $schedule Mage_Cron_Model_Schedule */
            $schedule->setCronExpr($cronExpression);
        } catch (Exception $e) {
            return false;
        }
        return true;
    }
233366
public function validate() {

		if ($this->getConsumedUnits() === null) {
			throw new ValidationException("'consumedUnits' can't be null", 'consumedUnits', $this);
		}
		if ($this->getExternalId() === null) {
			throw new ValidationException("'externalId' can't be null", 'externalId', $this);
		}
		if ($this->getMetric() === null) {
			throw new ValidationException("'metric' can't be null", 'metric', $this);
		}
		if ($this->getSubscription() === null) {
			throw new ValidationException("'subscription' can't be null", 'subscription', $this);
		}
	}
1354355
public function validateOptions()
    {
        if (!$this->rules instanceof AllOf) {
            throw new InvalidArgumentException('Validation rules are missing or invalid');
        }

        if (!$this->hasKey()) {
            throw new InvalidArgumentException('A key must be set');
        }

        if ($this->hasMessage() && !is_string($this->message)) {
            throw new InvalidArgumentException(sprintf('Expected custom message to be of type string, %s given', gettype($this->message)));
        }
    }
1067137
public function Validate()
	{
		// force re-validation
		$this->ResetValidationErrors();

		$is_valid = (!$this->HasValidationErrors());

		// if validation fails, remove this object from the cache otherwise invalid values can
		// hang around and cause troubles.
		if (!$is_valid)
		{
			$this->_phreezer->DeleteCache(get_class($this), $this->GetPrimaryKeyValue());
		}

		return $is_valid;
	}
358495
public function isValid()
    {
        $singleAssertion = $this->validateNumAssertions();
        if (!$singleAssertion) {
            throw new Exception('Multiple assertions are not supported');
        }

        $validTimestamps = $this->validateTimestamps();
        if (!$validTimestamps) {
            throw new Exception('Timing issues (please check your clock settings)');
        }

        $objXMLSecDSig = new XMLSecurityDSig();

        $objDSig = $objXMLSecDSig->locateSignature($this->_document);
        if (!$objDSig) {
            throw new Exception('Cannot locate Signature Node');
        }
        $objXMLSecDSig->canonicalizeSignedInfo();
        $objXMLSecDSig->idKeys = array('ID');

        $objKey = $objXMLSecDSig->locateKey();
        if (!$objKey) {
            throw new Exception('We have no idea about the key');
        }

        try {
            $objXMLSecDSig->validateReference();
        } catch (Exception $e) {
            throw new Exception('Reference Validation Failed');
        }

        XMLSecEnc::staticLocateKeyInfo($objKey, $objDSig);

        $objKey->loadKey($this->_settings->idpPublicCertificate, false, true);

        return ($objXMLSecDSig->verify($objKey) === 1);
    }
988033
private String validatePattern() {

        String error = null;
        switch (getPatternType()) {
            case DAILY:
                error = isEveryWorkingDay() ? null : validateInterval();
                break;
            case WEEKLY:
                error = validateInterval();
                if (null == error) {
                    error = validateWeekDaySet();
                }
                break;
            case MONTHLY:
                error = validateInterval();
                if (null == error) {
                    error = validateMonthSet();
                    if (null == error) {
                        error = isWeekDaySet() ? validateWeekOfMonthSet() : validateDayOfMonth();
                    }
                }
                break;
            case YEARLY:
                error = isWeekDaySet() ? validateWeekOfMonthSet() : validateDayOfMonth();
                break;
            case INDIVIDUAL:
            case NONE:
            default:
        }
        return error;
    }
909689
@Override
  public void validate () throws SchedulerException
  {
    super.validate ();

    if (m_eRepeatIntervalUnit == null ||
        !(m_eRepeatIntervalUnit.equals (EIntervalUnit.SECOND) ||
          m_eRepeatIntervalUnit.equals (EIntervalUnit.MINUTE) ||
          m_eRepeatIntervalUnit.equals (EIntervalUnit.HOUR)))
      throw new SchedulerException ("Invalid repeat IntervalUnit (must be SECOND, MINUTE or HOUR).");
    if (m_nRepeatInterval < 1)
    {
      throw new SchedulerException ("Repeat Interval cannot be zero.");
    }

    // Ensure interval does not exceed 24 hours
    final long secondsInHour = 24 * 60 * 60L;
    if (m_eRepeatIntervalUnit == EIntervalUnit.SECOND && m_nRepeatInterval > secondsInHour)
    {
      throw new SchedulerException ("repeatInterval can not exceed 24 hours (" +
                                    secondsInHour +
                                    " seconds). Given " +
                                    m_nRepeatInterval);
    }
    if (m_eRepeatIntervalUnit == EIntervalUnit.MINUTE && m_nRepeatInterval > secondsInHour / 60L)
    {
      throw new SchedulerException ("repeatInterval can not exceed 24 hours (" +
                                    secondsInHour / 60L +
                                    " minutes). Given " +
                                    m_nRepeatInterval);
    }
    if (m_eRepeatIntervalUnit == EIntervalUnit.HOUR && m_nRepeatInterval > 24)
    {
      throw new SchedulerException ("repeatInterval can not exceed 24 hours. Given " + m_nRepeatInterval + " hours.");
    }

    // Ensure timeOfDay is in order.
    if (getEndTimeOfDay () != null && !getStartTimeOfDay ().before (getEndTimeOfDay ()))
    {
      throw new SchedulerException ("StartTimeOfDay " +
                                    m_aStartTimeOfDay +
                                    " should not come after endTimeOfDay " +
                                    m_aEndTimeOfDay);
    }
  }
520007
@Override
	public boolean isValid() {
		boolean mustNotCache =
				has("Pragma", "no-cache", this.response)
				|| has("Cache-Control", "no-cache", this.response);

		if (mustNotCache)
			return false;

		Date now = new Date();
		Date cacheControl = getCacheControlExpiresDate();
		Date expires = getExpiresDate();

		return now.before(cacheControl) || now.before(expires);
	}
824059
public Cron parse(final String expression) {
        Preconditions.checkNotNull(expression, "Expression must not be null");
        final String replaced = expression.replaceAll("\\s+", " ").trim();
        if (StringUtils.isEmpty(replaced)) {
            throw new IllegalArgumentException("Empty expression!");
        }

        if(expression.contains("|")){
            List<String> crons = new ArrayList<>();
            int cronscount = Arrays.stream(expression.split("\\s+")).mapToInt(s->s.split("\\|").length).max().orElseGet(() -> 0);
            for(int j=0; j<cronscount; j++){
                StringBuilder builder = new StringBuilder();
                for(String s : expression.split("\\s+")){
                    if(s.contains("|")){
                        builder.append(String.format("%s ", s.split("\\|")[j]));
                    }else{
                        builder.append(String.format("%s ", s));
                    }
                }
                crons.add(builder.toString().trim());
            }
            return new CompositeCron(crons.stream().map(c->parse(c)).collect(Collectors.toList()));
        }else{
            final String[] expressionParts = replaced.toUpperCase().split(" ");
            final int expressionLength = expressionParts.length;
            String fieldWithTrailingCommas = Arrays.stream(expressionParts).filter(x -> x.endsWith(",")).findAny().orElse(null);
            if(fieldWithTrailingCommas!=null){
                throw new IllegalArgumentException(String.format("Invalid field value! Trailing commas not permitted! '%s'", fieldWithTrailingCommas));
            }
            final List<CronParserField> fields = expressions.get(expressionLength);
            if (fields == null) {
                throw new IllegalArgumentException(
                        String.format("Cron expression contains %s parts but we expect one of %s", expressionLength, expressions.keySet()));
            }
            try {
                final int size = fields.size();
                final List<CronField> results = new ArrayList<>(size + 1);
                for (int j = 0; j < size; j++) {
                    results.add(fields.get(j).parse(expressionParts[j]));
                }
                return new SingleCron(cronDefinition, results).validate();
            } catch (final IllegalArgumentException e) {
                throw new IllegalArgumentException(String.format("Failed to parse '%s'. %s", expression, e.getMessage()), e);
            }
        }
    }
852074
@Override public void validate() { 
    if (id == null || id.isEmpty()) {
      throw new IllegalArgumentException("missing or empty id");
    }
    Query.validateId(id);
  }
289763
protected function getValidCommand()
    {
        $datetimeFormat = $this->getDatetimeFormat();
        $type           = $this->type;
        $path           = $this->path;
        $command        = $this->command;
        $debug          = $this->debug;

        $match = '(\*|[0-9]{1,2}|\*\/[0-9]{1,2}|[0-9]{1,2}\s*\-\s*[0-9]{1,2}|(([0-9]{1,2})*\s*\,\s*[0-9]{1,2})+)\s+';

        if( ! preg_match('/^'.$match.$match.$match.$match.$match.'$/', $datetimeFormat) )
        {
            throw new InvalidTimeFormatException('Services', 'crontab:timeFormatError');
        }
        else
        {
            return $datetimeFormat.
                   ( ! empty($path)    ? $path    . ' ' : '' ).
                   ( ! empty($command) ? $command . ' ' : '' ).
                   ( ! empty($type)    ? $type    . ' ' : '' ).
                   ( $debug === true   ? '>> '    . $this->crontabDir . 'debug.log 2>&1' : '' );
        }
    }
933878
public function validate() {
        if (!$this->_data) {
            return false;
        }

        $fields = $this->getFields();
        $messages = $this->getMessages();

        foreach ($this->_data as $field => $value) {
            if (empty($this->_rules[$field])) {
                continue;
            }

            foreach ($this->_rules[$field] as $rule => $params) {
                $options = $params['options'];
                $arguments = $options;
                array_unshift($arguments, $value);

                // Use G11n if it is available
                if (class_exists('Titon\G11n\Utility\Validate')) {
                    $class = 'Titon\G11n\Utility\Validate';
                } else {
                    $class = 'Titon\Utility\Validate';
                }

                if (!call_user_func(array($class, 'hasMethod'), $rule)) {
                    throw new InvalidValidationRuleException(sprintf('Validation rule %s does not exist', $rule));
                }

                // Prepare messages
                $message = $params['message'];

                if (!$message && isset($messages[$rule])) {
                    $message = $messages[$rule];
                }

                if ($message) {
                    $message = String::insert($message, array_map(function($value) {
                        return is_array($value) ? implode(', ', $value) : $value;
                    }, $options + array(
                        'field' => $field,
                        'title' => $fields[$field]
                    )));
                } else {
                    throw new InvalidValidationRuleException(sprintf('Error message for rule %s does not exist', $rule));
                }

                if (!call_user_func_array(array($class, $rule), $arguments)) {
                    $this->addError($field, $message);
                    break;
                }
            }
        }

        return empty($this->_errors);
    }
6529
public void validate () throws SchedulerException
  {
    if (m_sName == null)
    {
      throw new SchedulerException ("Trigger's name cannot be null");
    }

    if (m_sGroup == null)
    {
      throw new SchedulerException ("Trigger's group cannot be null");
    }

    if (m_sJobName == null)
    {
      throw new SchedulerException ("Trigger's related Job's name cannot be null");
    }

    if (m_sJobGroup == null)
    {
      throw new SchedulerException ("Trigger's related Job's group cannot be null");
    }
  }
610157
protected final boolean isPatternValid() {

        switch (getPatternType()) {
            case DAILY:
                return isEveryWorkingDay() || isIntervalValid();
            case WEEKLY:
                return isIntervalValid() && isWeekDaySet();
            case MONTHLY:
                return isIntervalValid() && isWeekDaySet() ? isWeekOfMonthSet() : isDayOfMonthValid();
            case YEARLY:
                return isMonthSet() && isWeekDaySet() ? isWeekOfMonthSet() : isDayOfMonthValid();
            case INDIVIDUAL:
            case NONE:
                return true;
            default:
                return false;
        }
    }
595964
@Override
  public OperableTrigger instantiate() {

    CronTriggerImpl ct = new CronTriggerImpl();

    try {
      ct.setCronExpression(cronExpression);
    } catch (ParseException e) {
      // all methods of construction ensure the expression is valid by this point...
      throw new RuntimeException(
          "CronExpression '"
              + cronExpression
              + "' is invalid, which should not be possible, please report bug to Quartz developers.");
    }
    ct.setTimeZone(tz);
    ct.setMisfireInstruction(misfireInstruction);

    return ct;
  }