Validate periodic input
337844
def _check_periodic(periodic):
    ''''''
    periodic = np.array(periodic)

    # If it is a matrix
    if len(periodic.shape) == 2:
        assert periodic.shape[0] == periodic.shape[1], 'periodic shoud be a square matrix or a flat array'
        return np.diag(periodic)
    elif len(periodic.shape) == 1:
        return periodic
    else:
        raise ValueError("periodic argument can be either a 3x3 matrix or a shape 3 array.")
638337
function (json, callback) {
        //validate input
        if (!inputValidation(json)) {
            var inputError = new SearchError('invalid input');
            callback(undefined, inputError);
            return;
        }
        //make end date last millisecond of the day
        var end = new Date(json.date);
        end.setHours(23);
        end.setMinutes(59);
        end.setSeconds(59);
        end.setMilliseconds(999);
        end = end.toISOString();
        //ensure start date is at 00:00:000
        var start = new Date(json.date);
        start.setHours(0);
        start.setMinutes(0);
        start.setSeconds(0);
        start.setMilliseconds(0);
        start = start.toISOString();

        database.getSentimentForNameTimeframe(json.character, start, end, function (json, err) {
            if (err) {
                callback(undefined, err);
            } else {
                var result = {};
                var posSentDaily = 0;
                var negSentDaily = 0;
                var posDaily = 0;
                var negDaily = 0;
                var nullDaily = 0;
                for (var i in json) {
                    posSentDaily += json[i].posSum;
                    negSentDaily += json[i].negSum;
                    posDaily += json[i].posCount;
                    negDaily += json[i].negCount;
                    nullDaily += json[i].nullCount;
                }
                result.character = json[0].character;
                result.description = json[0].description;
                result.posSum = posSentDaily;
                result.negSum = negSentDaily;
                result.posCount = posDaily;
                result.negCount = negDaily;
                result.nullCount = nullDaily;
                result.date = start;
                callback(result);
            }
        });
    }
1181057
function parseRange (val, repeatInterval) {
    var stack = [];
    var atoms = val.split('-');

    if (atoms.length > 1 ) {
      // Invalid range, return value
      if (atoms.length < 2) {
        return +val;
      }

      if (!atoms[0].length) {
        if (!atoms[1].length) {
          throw new Error('Invalid range: ' + val);
        }

        return +val;
      }

      // Validate range
      var min = +atoms[0];
      var max = +atoms[1];

      if (safeIsNaN(min) || safeIsNaN(max) ||
          min < constraints[0] || max > constraints[1]) {
        throw new Error(
          'Constraint error, got range ' +
          min + '-' + max +
          ' expected range ' +
          constraints[0] + '-' + constraints[1]
        );
      } else if (min >= max) {
        throw new Error('Invalid range: ' + val);
      }

      // Create range
      var repeatIndex = +repeatInterval;

      if (safeIsNaN(repeatIndex) || repeatIndex <= 0) {
        throw new Error('Constraint error, cannot repeat at every ' + repeatIndex + ' time.');
      }

      for (var index = min, count = max; index <= count; index++) {
        if (repeatIndex > 0 && (repeatIndex % repeatInterval) === 0) {
          repeatIndex = 1;
          stack.push(index);
        } else {
          repeatIndex++;
        }
      }

      return stack;
    }

    return +val;
  }
648328
private Iterable<String> validate(final String input) {
        if (optional && input.isEmpty()) return Lists.newArrayList();
        return FluentIterable
                .from(validators)
                .filter(new Predicate<Validator>() {
                    @Override
                    public boolean apply(Validator validator) {
                        try {
                            return !validator.valid(input);
                        } catch (Exception e) {
                            return true;
                        }
                    }
                })
                .transform(new Function<Validator, String>() {
                    @Override
                    public String apply(Validator input) {
                        return input.message();
                    }
                });
    }
615667
private void validateTimes(int idx, SubPicture subPic,
			SubPicture subPicNext, SubPicture subPicPrev) {
		long startTime = subPic.getStartTime();
		long endTime = subPic.getEndTime();
		final long delay = 5000 * 90; // default delay for missing end time (5
										// seconds)

		idx += 1; // only used for display

		// get end time of last frame
		long lastEndTime = subPicPrev != null ? subPicPrev.getEndTime() : -1;

		if (startTime < lastEndTime) {
			startTime = lastEndTime;
		}

		// get start time of next frame
		long nextStartTime = subPicNext != null ? subPicNext.getStartTime() : 0;

		if (nextStartTime == 0) {
			if (endTime > startTime) {
				nextStartTime = endTime;
			} else {
				// completely messed up:
				// end time and next start time are invalid
				nextStartTime = startTime + delay;
			}
		}

		if (endTime <= startTime) {
			endTime = startTime + delay;
			if (endTime > nextStartTime) {
				endTime = nextStartTime;
			}
		} else if (endTime > nextStartTime) {
			endTime = nextStartTime;
		}

		int minTimePTS = configuration.getMinTimePTS();
		if (endTime - startTime < minTimePTS) {
			if (configuration.getFixShortFrames()) {
				endTime = startTime + minTimePTS;
				if (endTime > nextStartTime) {
					endTime = nextStartTime;
				}
			}
		}

		if (subPic.getStartTime() != startTime) {
			subPic.setStartTime(SubtitleUtils.syncTimePTS(startTime,
					configuration.getFpsTrg(), configuration.getFpsTrg()));
		}
		if (subPic.getEndTime() != endTime) {
			subPic.setEndTime(SubtitleUtils.syncTimePTS(endTime,
					configuration.getFpsTrg(), configuration.getFpsTrg()));
		}
	}
388845
def validateStringInput(input_key,input_data, read=False):
    
    log = clog.error_log
    func = None
    if '*' in input_data or '%' in input_data:
        func = validationFunctionWildcard.get(input_key)
        if func is None:
            func = searchstr
    elif input_key == 'migration_input' :
        if input_data.find('#') != -1 : func = block
        else : func = dataset
    else:
        if not read:
            func = validationFunction.get(input_key)
            if func is None:
                func = namestr
        else:
            if input_key == 'dataset':
                func = reading_dataset_check
            elif input_key == 'block_name':
                func = reading_block_check
            elif input_key == 'logical_file_name':
                func = reading_lfn_check
            else:
                func = namestr
    try:
        func(input_data)
    except AssertionError as ae:
        serverLog = str(ae) + " key-value pair (%s, %s) cannot pass input checking" %(input_key, input_data)
        #print serverLog
        dbsExceptionHandler("dbsException-invalid-input2", message="Invalid Input Data %s...:  Not Match Required Format" %input_data[:10], \
            logger=log.error, serverError=serverLog)
    return input_data
1175907
private void validateSameDay(ProjectCalendar calendar, LinkedList<TimephasedWork> list)
   {
      for (TimephasedWork assignment : list)
      {
         Date assignmentStart = assignment.getStart();
         Date calendarStartTime = calendar.getStartTime(assignmentStart);
         Date assignmentStartTime = DateHelper.getCanonicalTime(assignmentStart);
         Date assignmentFinish = assignment.getFinish();
         Date calendarFinishTime = calendar.getFinishTime(assignmentFinish);
         Date assignmentFinishTime = DateHelper.getCanonicalTime(assignmentFinish);
         double totalWork = assignment.getTotalAmount().getDuration();

         if (assignmentStartTime != null && calendarStartTime != null)
         {
            if ((totalWork == 0 && assignmentStartTime.getTime() != calendarStartTime.getTime()) || (assignmentStartTime.getTime() < calendarStartTime.getTime()))
            {
               assignmentStart = DateHelper.setTime(assignmentStart, calendarStartTime);
               assignment.setStart(assignmentStart);
            }
         }

         if (assignmentFinishTime != null && calendarFinishTime != null)
         {
            if ((totalWork == 0 && assignmentFinishTime.getTime() != calendarFinishTime.getTime()) || (assignmentFinishTime.getTime() > calendarFinishTime.getTime()))
            {
               assignmentFinish = DateHelper.setTime(assignmentFinish, calendarFinishTime);
               assignment.setFinish(assignmentFinish);
            }
         }
      }
   }
964357
def verify_month(self, now):
        ''''''
        return self.month == "*" or str(now.month) in self.month.split(" ")
896989
def validate_time(self, duration=False):
        
        super(TimeFilter, self).validate()
        timestamp = now = time.time()

        if str(self._value).isdigit():
            # Literal UNIX timestamp
            try:
                timestamp = float(self._value)
            except (ValueError, TypeError), exc:
                raise FilterError("Bad timestamp value %r in %r (%s)" % (self._value, self._condition, exc))
        else:
            # Something human readable
            delta = self.TIMEDELTA_RE.match(self._value)
            ##print self.TIMEDELTA_RE.pattern
            if delta:
                # Time delta
                for unit, val in delta.groupdict().items():
                    if val:
                        timestamp = self.TIMEDELTA_UNITS[unit](timestamp, int(val, 10))

                if duration:
                    timestamp = now - timestamp
                else:
                    # Invert logic for time deltas (+ = older; - = within the delta range)
                    if self._cmp == operator.lt:
                        self._cmp = operator.gt
                        self._rt_cmp = 'greater'
                    elif self._cmp == operator.gt:
                        self._cmp = operator.lt
                        self._rt_cmp = 'less'
            else:
                # Assume it's an absolute date
                if '/' in self._value:
                    # U.S.
                    dtfmt = "%m/%d/%Y"
                elif '.' in self._value:
                    # European
                    dtfmt = "%d.%m.%Y"
                else:
                    # Fall back to ISO
                    dtfmt = "%Y-%m-%d"

                val = str(self._value).upper().replace(' ', 'T')
                if 'T' in val:
                    # Time also given
                    dtfmt += "T%H:%M:%S"[:3+3*val.count(':')]

                try:
                    timestamp = time.mktime(time.strptime(val, dtfmt))
                except (ValueError), exc:
                    raise FilterError("Bad timestamp value %r in %r (%s)" % (self._value, self._condition, exc))

                if duration:
                    timestamp -= now

        self._value = timestamp
940548
function repeat(input, n) {

    var times = ~~n;

    return (!isString(input) || !times) ? input : strRepeat(input, n);
}
820484
function (monthStr) {
			var mon = (monthStr && monthStr.toLowerCase());
			return _.isString(mon) && (map[mon] || map[mon.substr(0,3)]);
		}
901024
@Override
    public boolean isValid(Object input) {
        long epochMillisec;
        try {
            epochMillisec = Long.parseLong(input.toString());
        } catch (NumberFormatException e) {
            return false;
        }

        if (minValidTime != null && epochMillisec < minValidTime)
            return false;
        return !(maxValidTime != null && epochMillisec > maxValidTime);
    }
166261
public function validate($input): bool
    {
        if ($input instanceof DateTime) {
            return true;
        }

        if (!\is_string($input)) {
            return false;
        }

        if (null === $this->format) {
            return false !== strtotime($input);
        }

        $dateFromFormat = DateTime::createFromFormat($this->format, $input);

        return $dateFromFormat
            && $input === date($this->format, $dateFromFormat->getTimestamp());
    }
502928
function validateEach(value, elem) {
			var inst = $.calendarsPicker._getInst(elem);
			var dates = (inst.options.multiSelect ? value.split(inst.options.multiSeparator) :
				(inst.options.rangeSelect ? value.split(inst.options.rangeSeparator) : [value]));
			var ok = (inst.options.multiSelect && dates.length <= inst.options.multiSelect) ||
				(!inst.options.multiSelect && inst.options.rangeSelect && dates.length === 2) ||
				(!inst.options.multiSelect && !inst.options.rangeSelect && dates.length === 1);
			if (ok) {
				try {
					var dateFormat = inst.get('dateFormat');
					var minDate = inst.get('minDate');
					var maxDate = inst.get('maxDate');
					var cp = $(elem);
					$.each(dates, function(i, v) {
						dates[i] = inst.options.calendar.parseDate(dateFormat, v);
						ok = ok && (!dates[i] || (cp.calendarsPicker('isSelectable', dates[i]) &&
							(!minDate || dates[i].compareTo(minDate) !== -1) &&
							(!maxDate || dates[i].compareTo(maxDate) !== +1)));
					});
				}
				catch (e) {
					ok = false;
				}
			}
			if (ok && inst.options.rangeSelect) {
				ok = (dates[0].compareTo(dates[1]) !== +1);
			}
			return ok;
		}
1283371
function validateSwipeTime() {
			var result;
			//If no time set, then return true

			if (options.maxTimeThreshold) {
				if (duration >= options.maxTimeThreshold) {
					result = false;
				} else {
					result = true;
				}
			}
			else {
				result = true;
			}

			return result;
		}
1009372
protected void validateField(int field) {
        int y;
        switch (field) {
        case DAY_OF_MONTH:
            y = handleGetExtendedYear();
            validateField(field, 1, handleGetMonthLength(y, internalGet(MONTH)));
            break;
        case DAY_OF_YEAR:
            y = handleGetExtendedYear();
            validateField(field, 1, handleGetYearLength(y));
            break;
        case DAY_OF_WEEK_IN_MONTH:
            if (internalGet(field) == 0) {
                throw new IllegalArgumentException("DAY_OF_WEEK_IN_MONTH cannot be zero");
            }
            validateField(field, getMinimum(field), getMaximum(field));
            break;
        default:
            validateField(field, getMinimum(field), getMaximum(field));
            break;
        }
    }
1147465
function(input) {
		var needstesting = !this._matches.length;
		if (needstesting || this._matches.every(function(match) {
			return match.$instanceid !== input.$instanceid;
		})) {
			return this._maybeinput(input);
		}
		return false;
	}