////////////////////////////////////////////////////////////////////////////////
/////                 Validation of range queries
////////////////////////////////////////////////////////////////////////////////
184757
func (v *Validator) validateRangeQueries(ns string, rangeQueriesInfo []*kvrwset.RangeQueryInfo, updates *privacyenabledstate.PubUpdateBatch) (bool, error) {
	for _, rqi := range rangeQueriesInfo {
		if valid, err := v.validateRangeQuery(ns, rqi, updates); !valid || err != nil {
			return valid, err
		}
	}
	return true, nil
}
108527
function isWildcardRange(range, constraints) {
  if (range instanceof Array && !range.length) {
    return false;
  }

  if (constraints.length !== 2) {
    return false;
  }

  return range.length === (constraints[1] - (constraints[0] < 1 ? - 1 : 0));
}
37703
private void validateQuery(Query query) throws IllegalArgumentException {
    if (query.getKindCount() != 1) {
      throw new IllegalArgumentException("Query must have exactly one kind.");
    }
    if (query.getOrderCount() != 0) {
      throw new IllegalArgumentException("Query cannot have any sort orders.");
    }
    if (query.hasFilter()) {
      validateFilter(query.getFilter());
    }
  }
886775
def validate_VALUERANGE(in_value, restriction):
    
    if len(restriction) != 2:
        raise ValidationError("Template ERROR: Only two values can be specified in a date range.")
    value = _get_val(in_value)
    if type(value) is list:
        for subval in value:
            if type(subval) is tuple:
                subval = subval[1]
            validate_VALUERANGE(subval, restriction)
    else:
        min_val = Decimal(restriction[0])
        max_val = Decimal(restriction[1])
        val     = Decimal(value)
        if val < min_val or val > max_val:
            raise ValidationError("VALUERANGE: %s, %s"%(min_val, max_val))
352235
function range(begin, end) {
  return test(function(ch) {
    return begin <= ch && ch <= end;
  }).desc(begin + "-" + end);
}
1201983
def _validate_range(self, max_, min_, max_ex, min_ex, value, path, prefix):
        
        if not isinstance(value, int) and not isinstance(value, float):
            raise CoreError("Value must be a integer type")

        log.debug(
            u"Validate range : %s : %s : %s : %s : %s : %s",
            max_,
            min_,
            max_ex,
            min_ex,
            value,
            path,
        )

        if max_ is not None and max_ < value:
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Type '{prefix}' has size of '{value}', greater than max limit '{max_}'. Path: '{path}'",
                    path=path,
                    value=nativestr(value) if tt['str'](value) else value,
                    prefix=prefix,
                    max_=max_))

        if min_ is not None and min_ > value:
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Type '{prefix}' has size of '{value}', less than min limit '{min_}'. Path: '{path}'",
                    path=path,
                    value=nativestr(value) if tt['str'](value) else value,
                    prefix=prefix,
                    min_=min_))

        if max_ex is not None and max_ex <= value:
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Type '{prefix}' has size of '{value}', greater than or equals to max limit(exclusive) '{max_ex}'. Path: '{path}'",
                    path=path,
                    value=nativestr(value) if tt['str'](value) else value,
                    prefix=prefix,
                    max_ex=max_ex))

        if min_ex is not None and min_ex >= value:
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Type '{prefix}' has size of '{value}', less than or equals to min limit(exclusive) '{min_ex}'. Path: '{path}'",
                    path=path,
                    value=nativestr(value) if tt['str'](value) else value,
                    prefix=prefix,
                    min_ex=min_ex))
521445
@SuppressWarnings("unused")
  private List<Long> getValidationOutputFromHiveJdbc(List<String> queries) throws IOException {
    if (null == queries || queries.size() == 0) {
      log.warn("No queries specified to be executed");
      return Collections.emptyList();
    }
    Statement statement = null;
    List<Long> rowCounts = Lists.newArrayList();
    Closer closer = Closer.create();

    try {
      HiveJdbcConnector hiveJdbcConnector = HiveJdbcConnector.newConnectorWithProps(props);
      statement = hiveJdbcConnector.getConnection().createStatement();

      for (String query : queries) {
        log.info("Executing query: " + query);
        boolean result = statement.execute(query);
        if (result) {
          ResultSet resultSet = statement.getResultSet();
          if (resultSet.next()) {
            rowCounts.add(resultSet.getLong(1));
          }
        } else {
          log.warn("Query output for: " + query + " : " + result);
        }
      }

    } catch (SQLException e) {
      throw new RuntimeException(e);
    } finally {
      try {
        closer.close();
      } catch (Exception e) {
        log.warn("Could not close HiveJdbcConnector", e);
      }
      if (null != statement) {
        try {
          statement.close();
        } catch (SQLException e) {
          log.warn("Could not close Hive statement", e);
        }
      }
    }

    return rowCounts;
  }
696969
private static void rangeCheck(int length, int fromIndex, int toIndex) {
        if (fromIndex > toIndex) {
            throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")");
        }
        if (fromIndex < 0) {
            throw new ArrayIndexOutOfBoundsException(fromIndex);
        }
        if (toIndex > length) {
            throw new ArrayIndexOutOfBoundsException(toIndex);
        }
    }
1337863
function rangeFromIndexAndOffsets(i, before, after, length) {
  return {
    // Guard against the negative upper bound for lines included in the output.
    from: i - before > 0 ? i - before : 0,
    to: i + after > length ? length : i + after
  };
}
613967
public boolean contains(final CharRange range) {
        Validate.isTrue(range != null, "The Range must not be null");
        if (negated) {
            if (range.negated) {
                return start >= range.start && end <= range.end;
            }
            return range.end < start || range.start > end;
        }
        if (range.negated) {
            return start == 0 && end == Character.MAX_VALUE;
        }
        return start <= range.start && end >= range.end;
    }
477998
def validate_range_values(request, label, kwargs):
    """"""
    value = kwargs.get(label, request.query.get(label))
    if value:
        kwargs[label] = int(value)
        if kwargs[label] < 0 or kwargs[label] > MAX_PAGE_SIZE:
            raise ValueError
1169816
function RangeIterator(range) {
	this.range = range;
	if (range.collapsed)
		return;

//[TODO] ensure this works
	// get anchors
	var root = range.commonAncestorContainer;
	this._next = range.startContainer == root && !DOMUtils.isDataNode(range.startContainer) ?
	    range.startContainer.childNodes[range.startOffset] :
	    DOMUtils.findClosestAncestor(root, range.startContainer);
	this._end = range.endContainer == root && !DOMUtils.isDataNode(range.endContainer) ?
	    range.endContainer.childNodes[range.endOffset] :
	    DOMUtils.findClosestAncestor(root, range.endContainer).nextSibling;
}
1283262
private boolean validateRange(Range range, long contentLength)
   {
      long start = range.getStart();
      long end = range.getEnd();

      // range set as bytes:-100
      // take 100 bytes from end
      if (start < 0 && end == -1)
      {
         if ((-1 * start) >= contentLength)
         {
            start = 0;
            end = contentLength - 1;
         }
         else
         {
            start = contentLength + start;
            end = contentLength - 1;
         }
      }

      // range set as bytes:100-
      // take from 100 to the end
      if (start >= 0 && end == -1)
         end = contentLength - 1;

      // normal range set as bytes:100-200
      // end can be greater then content-length
      if (end >= contentLength)
         end = contentLength - 1;

      if (start >= 0 && end >= 0 && start <= end)
      {
         range.setStart(start);
         range.setEnd(end);
         return true;
      }
      return false;
   }
741874
@Override
  protected void removeRange(int fromIndex, int toIndex) {
    rangeCheck(fromIndex, toIndex);
    for (int i = fromIndex, j = toIndex; j < size; j++) {
      elements[i] = elements[j];
    }
    size -= (toIndex - fromIndex);
  }
1182422
function isInRange(node, reference) {
    const or = node.range;
    const ir = reference.identifier.range;

    return or[0] <= ir[0] && ir[1] <= or[1];
}
1282211
@Override
  public void exitSemantic_range(VersionParser.Semantic_rangeContext ctx) {
    String operator = ctx.getChild(0).getText();
    Object o = stack.pop();
    if (o instanceof SemanticVersion) {
      switch (operator) {
        case "^":
          SemanticVersion sv = (SemanticVersion) o;
          VersionRange from = new VersionRange(">=", sv);
          VersionRange to = new VersionRange("<", sv.getNextCaretVersion());
          range = new AndRange(from, to);
          break;
      }
      stack.push(range);
    }
    else {
      throw new InvalidRangeRuntimeException("Expected a semantic version, got a " + o.getClass().getSimpleName());
    }
  }
1159947
private void checkVariableRange(int ch, String rule, int start) {
        if (ch >= curData.variablesBase && ch < variableLimit) {
            syntaxError("Variable range character in rule", rule, start);
        }
    }