Fail if the algo has passed this Asset's end_date, or before the
        Asset's start date.
181969
def validate(self,
                 asset,
                 amount,
                 portfolio,
                 algo_datetime,
                 algo_current_data):
        
        # If the order is for 0 shares, then silently pass through.
        if amount == 0:
            return

        normalized_algo_dt = pd.Timestamp(algo_datetime).normalize()

        # Fail if the algo is before this Asset's start_date
        if asset.start_date:
            normalized_start = pd.Timestamp(asset.start_date).normalize()
            if normalized_algo_dt < normalized_start:
                metadata = {
                    'asset_start_date': normalized_start
                }
                self.handle_violation(
                    asset, amount, algo_datetime, metadata=metadata)
        # Fail if the algo has passed this Asset's end_date
        if asset.end_date:
            normalized_end = pd.Timestamp(asset.end_date).normalize()
            if normalized_algo_dt > normalized_end:
                metadata = {
                    'asset_end_date': normalized_end
                }
                self.handle_violation(
                    asset, amount, algo_datetime, metadata=metadata)
914888
def validate(self,
                 asset,
                 amount,
                 portfolio,
                 algo_datetime,
                 algo_current_data):
        

        if self.asset is not None and self.asset != asset:
            return

        if self.max_shares is not None and abs(amount) > self.max_shares:
            self.handle_violation(asset, amount, algo_datetime)

        current_asset_price = algo_current_data.current(asset, "price")
        order_value = amount * current_asset_price

        too_much_value = (self.max_notional is not None and
                          abs(order_value) > self.max_notional)

        if too_much_value:
            self.handle_violation(asset, amount, algo_datetime)
218525
def validate(self,
                 asset,
                 amount,
                 portfolio,
                 algo_datetime,
                 algo_current_data):
        
        if portfolio.positions[asset].amount + amount < 0:
            self.handle_violation(asset, amount, algo_datetime)
702833
def validate(self,
                 asset,
                 amount,
                 portfolio,
                 algo_datetime,
                 algo_current_data):
        

        if self.asset is not None and self.asset != asset:
            return

        current_share_count = portfolio.positions[asset].amount
        shares_post_order = current_share_count + amount

        too_many_shares = (self.max_shares is not None and
                           abs(shares_post_order) > self.max_shares)
        if too_many_shares:
            self.handle_violation(asset, amount, algo_datetime)

        current_price = algo_current_data.current(asset, "price")
        value_post_order = shares_post_order * current_price

        too_much_value = (self.max_notional is not None and
                          abs(value_post_order) > self.max_notional)

        if too_much_value:
            self.handle_violation(asset, amount, algo_datetime)
620793
public function checkValidTimes(Carbon $startDate, Carbon $endDate, $throwErrors = true)
    {
        if (Carbon::now()->between($startDate, $endDate)) {
            return true;
        } else {
            if ($throwErrors) {
                throw new CouponException('This coupon has expired');
            } else {
                return false;
            }
        }
    }
119220
static boolean isBefore(Date a, Date b) {
        return a == null || (b != null && b.before(a));
    }
623400
function passBiz (date, term) {
  date = this.toDate(date);
  if (!date) {
    return null;
  }
  var from = this.toDate(this.from(date, term));
  return from ? countFromTo(this, from, date) : null;
}
339405
function isIn(asset, rules) {
    for (let i = 0, len = rules.length; i < len; i++) {
        let rule = rules[i];
        if (typeof rule === 'function' && rule.call(this, asset)) {
            return true;
        }
        else if (typeof rule === 'object' && rule instanceof RegExp && rule.test(asset)) {
            return true;
        }
        else if (typeof rule === 'string' && asset.endsWith(rule)) {
            return true;
        }
    }

    return false;
}
864290
public static boolean isBetween(final Date start, final Date end, final Date between)
	{
		final long min = start.getTime();
		final long max = end.getTime();
		final long index = between.getTime();
		return min <= index && index <= max;
	}
1209949
def validate(self):
    
    if not self.start:
      raise ValueError("Event has no start date")

    if not self.end:
      raise ValueError("Event has no end date")

    if self.end < self.start:
      raise ValueError("Start date is after end date")

    if self.reminder_minutes_before_start and not isinstance(self.reminder_minutes_before_start, int):
      raise TypeError("reminder_minutes_before_start must be of type int")

    if self.is_all_day and not isinstance(self.is_all_day, bool):
      raise TypeError("is_all_day must be of type bool")
141481
def set_run_completed(self, boolean, start_datetime, end_datetime):
        """"""
        self._run_completed = boolean

        if (start_datetime, end_datetime) != (None, None):
            # start_datetime: Sat Feb 28 23:54:27 2015
            # end_datetime: Sat Feb 28 23:54:30 2015
            try:
                fmt = "%a %b %d %H:%M:%S %Y"
                self.start_datetime = datetime.datetime.strptime(start_datetime, fmt)
                self.end_datetime = datetime.datetime.strptime(end_datetime, fmt)
            except Exception as exc:
                # Maybe LOCALE != en_US
                logger.warning(str(exc))
806580
function hasBlindPositionExpired(expiryTimestampString) {
    var now = new Date();
    if (expiryTimestampString) {
      var expiry = new Date(expiryTimestampString);
      return now > expiry;
    } else {
      return true;
    }
  }
786974
def validate_input parameters
				unless parameters.is_a?(Hash)
					raise StockException, 'Given parameters have to be a hash.'
				end

				# Check if stock symbol is specified.
				unless parameters.has_key?(:symbol)
					raise StockException, 'No stock symbol specified.'
				end
				# Check if stock symbol is a string.
				unless parameters[:symbol].is_a?(String)
					raise StockException, 'Stock symbol must be a string.'
				end

				# Use today date if :end_date is not specified.
				unless parameters.has_key?(:end_date)
					parameters[:end_date] = Date.today.strftime("%Y-%m-%d")
				end

				unless parameters.has_key?(:start_date)
					raise StockException, 'Start date must be specified.'
				end
	 			
				unless DATE_REGEX.match(parameters[:start_date])
					raise StockException, 'Invalid start date specified. Format YYYY-MM-DD.'
				end

				unless DATE_REGEX.match(parameters[:end_date])
					raise StockException, 'Invalid end date specified. Format YYYY-MM-DD.'
				end

				unless parameters[:start_date].to_date < parameters[:end_date].to_date
					raise StockException, 'End date must be greater than the start date.'
				end

				unless parameters[:start_date].to_date < Date.today
					raise StockException, 'Start date must not be in the future.'
				end

				# Set to default :type if key isn't specified.
				parameters[:type] = :daily if !parameters.has_key?(:type)

				unless TYPE_CODES_ARRAY.has_key?(parameters[:type])
					raise StockException, 'Invalid type specified.'
				end
			end
364022
def check_expiration
      return if has_role?('Administrator')
      if expired_at
        if expired_at.beginning_of_day < Time.zone.now.beginning_of_day
          lock_access! if active_for_authentication?
        end
      end
    end
816353
def _sanitize_dates(start, end):
    
    if isinstance(start, int):
        # regard int as year
        start = datetime(start, 1, 1)
    start = to_datetime(start)

    if isinstance(end, int):
        end = datetime(end, 1, 1)
    end = to_datetime(end)

    if start is None:
        start = datetime(2015, 1, 1)
    if end is None:
        end = datetime.today()
    if start > end:
        raise ValueError('start must be an earlier date than end')
    return start, end
734938
def _ValidateClosedTimeRange(time_range):
  """"""
  time_range_start, time_range_end = time_range
  _ValidateTimestamp(time_range_start)
  _ValidateTimestamp(time_range_end)
  if time_range_start > time_range_end:
    raise ValueError("Invalid time-range: %d > %d." %
                     (time_range_start.AsMicrosecondsSinceEpoch(),
                      time_range_end.AsMicrosecondsSinceEpoch()))
822700
function _startAssetGeneration(id) {
        if (_waitingDocuments.hasOwnProperty(id)) {
            return;
        }

        var documentPromise = _documentManager.getDocument(id);
        
        _waitingDocuments[id] = documentPromise;

        documentPromise.done(function (document) {
            delete _waitingDocuments[id];

            if (_canceledDocuments.hasOwnProperty(id)) {
                delete _canceledDocuments[id];
            } else {
                if (!_assetManagers.hasOwnProperty(id)) {
                    _assetManagers[id] = new AssetManager(_generator, _config, _logger, document, _renderManager);

                    document.on("closed", _stopAssetGeneration.bind(undefined, id));
                    document.on("end", _restartAssetGeneration.bind(undefined, id));
                    document.on("file", _handleFileChange.bind(undefined, id));
                }
                _assetManagers[id].start();
            }
        });
    }