This method limit val between 1 to max
val and max both are passed as string
332351
function limit(val, max) {
  if (val.length === 1 && val[0] > max[0]) {
    val = '0' + val;
  }

  if (val.length === 2) {
    if (Number(val) === 0) {
      val = '01';

    //this can happen when user paste number
  } else if (val > max) {
      val = max;
    }
  }

  return val;
}
1002177
def maxValue(self, value):
        """"""
        if isinstance(value, [int, float, long]):
            self._rangeMax = value
635116
function getMinMaxValuesRange(arr) {
    let maxValue = Number.MIN_VALUE;
    let minValue = Number.MAX_VALUE;
    arr
      .forEach((d) => {
        if (d.value > maxValue) {
          maxValue = d.value;
        }
        if (d.valueLow < minValue) {
          minValue = d.valueLow;
        }
      });
      return {maxValue, minValue};
  }
267020
public static long maximum(long... values)
    {
        int len = values.length;
        long current = values[0];

        for (int i=1; i < len; i++)
        {
            current = Math.max(values[i], current);
        }

        return current;
    }
840372
def typed_range(type_func, minimum, maximum):
    
    @functools.wraps(type_func)
    def inner(string):
        result = type_func(string)
        if not result >= minimum and result <= maximum:
            raise argparse.ArgumentTypeError(
                    "Please provide a value between {0} and {1}".format(
                        minimum, maximum))
        return result
    return inner
560189
def _max(self):
        """"""
        return (
            self.range[1] if (self.range and self.range[1] is not None) else
            (max(self._values) if self._values else None)
        )
341668
function limit() {
  const args = Array.from(arguments);
  const onChange = get(args, isFunction, noop);
  const error = new Error('Too Many Requests');
  error.status = 429;
  const options = Object.assign({
    err: error,
    mid: 100,
    high: 500,
  }, get(args, isObject));
  debug('limit options:', options);
  const mid = parseInt(options.mid, 10);
  const high = parseInt(options.high, 10);
  if (isNaN(mid) || isNaN((high))) {
    throw new Error('mid and high must be a number');
  }
  if (mid <= 0 || high <= 0) {
    throw new Error('mid and high must gt 0');
  }
  if (mid >= high) {
    throw new Error('high must be gt mid');
  }
  let handlingReqTotal = 0;
  let status = '';
  let throwError = options.throwError;
  /* istanbul ignore else */
  if (isUndefined(throwError)) {
    throwError = true;
  }
  const pass = options.pass || noop;
  return (ctx, next) => {
    function checkStatus() {
      if (handlingReqTotal > high) {
        /* istanbul ignore else */
        if (status !== 'high') {
          status = 'high';
          onChange(status);
        }
        /* istanbul ignore else */
        if (throwError) {
          throw options.err;
        }
      } else if (handlingReqTotal > mid) {
        /* istanbul ignore else */
        if (status !== 'mid') {
          status = 'mid';
          onChange(status);
        }
      } /* istanbul ignore else */ else if (status !== 'low') {
        status = 'low';
        onChange(status);
      }
    }

    function done(err) {
      handlingReqTotal -= 1;
      checkStatus();
      if (err) {
        throw err;
      }
    }
    if (pass(ctx)) {
      return next();
    }

    handlingReqTotal += 1;
    checkStatus();
    return next().then(done, done);
  };
}
359298
private int[] getRange(String field, int min, int max) {
        int[] result = new int[2];
        if (field.contains("*")) {
            result[0] = min;
            result[1] = max - 1;
            return result;
        }
        if (!field.contains("-")) {
            result[0] = result[1] = Integer.valueOf(field);
        } else {
            String[] split = StringUtils.delimitedListToStringArray(field, "-");
            if (split.length > 2) {
                throw new IllegalArgumentException("Range has more than two fields: '" + field + "' in expression \""
                        + this.expression + "\"");
            }
            result[0] = Integer.valueOf(split[0]);
            result[1] = Integer.valueOf(split[1]);
        }
        if (result[0] >= max || result[1] >= max) {
            throw new IllegalArgumentException("Range exceeds maximum (" + max + "): '" + field + "' in expression \""
                    + this.expression + "\"");
        }
        if (result[0] < min || result[1] < min) {
            throw new IllegalArgumentException("Range less than minimum (" + min + "): '" + field
                    + "' in expression \"" + this.expression + "\"");
        }
        return result;
    }
66165
function valueStrim(value, cutoff) {
        var strimLimit = typeof cutoff === 'undefined' ? 60 : cutoff;

        var t = typeof value;
        if (t === 'function') {
          return '[function]';
        }
        if (t === 'object') {
          value = JSON.stringify(value);
          if (value.length > strimLimit) {
            value = value.substr(0, strimLimit) + '...';
          }
          return value;
        }
        if (t === 'string') {
          if (value.length > strimLimit) {
            return JSON.stringify(value.substr(0, strimLimit)) + '...';
          }
          return JSON.stringify(value);
        }
        return '' + value;
      }
137378
function calculateMaxValue(maximum) {
    var distance = ($attrs.distance || '2.5%').trim();
    var isPercent = distance.indexOf('%') !== -1;
    return isPercent ?
    maximum * (1 - parseFloat(distance) / 100) :
    maximum - parseFloat(distance);
  }
362615
def limit_value_string_length(value):
    
    if isinstance(value, string_types) and len(value) > constants.MAX_VALUE_LABEL_TEXT_LENGTH:
        value = value[:constants.MAX_VALUE_LABEL_TEXT_LENGTH] + "..."
        final_string = " " + value + " "
    elif isinstance(value, (dict, list)) and len(str(value)) > constants.MAX_VALUE_LABEL_TEXT_LENGTH:
        value_text = str(value)[:constants.MAX_VALUE_LABEL_TEXT_LENGTH] + "..."
        final_string = " " + value_text + " "
    else:
        final_string = " " + str(value) + " "

    return final_string
108094
boolean allowsValue(String str, ValidationContext vc) {
    try {
      getValue(str, vc);
      return true;
    }
    catch (DatatypeException e) {
      return false;
    }
  }
705655
function () {
            var value, binding = this._binding;
            if (!binding) {
                return;
            }
            value = binding.inside[binding.to];
            if (ariaUtilsType.isArray(value)) {
                // Constrain values to be between 0 and 1 and the first to be smaller
                this.value[0] = Math.max(0, Math.min(value[0], value[1], 1));
                this.value[1] = Math.min(1, Math.max(value[0], value[1], 0));
            }
            ariaUtilsJson.setValue(binding.inside, binding.to, this.value, this._bindingCallback);
        }
1282305
private void onLimit(StringBuilder builder) {
        if (Integer.MAX_VALUE != maxResult) {
            builder.append(CQLTranslator.LIMIT);
            builder.append(isSingleResult ? 1 : this.maxResult);
        }
    }
838845
function(value, maxLen, padChar) {
        value = value || '';
        return value + _getPadString(value, maxLen, padChar);
    }
1155535
private int parseDMax(String dMaxString) {
		int dMax;
		try {
			dMax = Integer.parseInt(dMaxString);
		} catch (NumberFormatException e) {
			dMax = 0;
		}
		return dMax;
	}
107677
public static function numericRange(
        float $value,
        float $min,
        float $max,
        ?string $message = null,
        ?string $propertyPath = null
    ) : void {
        static::numeric($value);
        static::numeric($min);
        static::numeric($max);

        if ($value < $min || $value > $max) {
            $message = sprintf(
                $message ?: 'Value %d is not between %d and %d',
                static::stringify($value),
                static::stringify($min),
                static::stringify($max)
            );

            throw static::createException($value, $message, static::INVALID_NUMERIC_RANGE, $propertyPath);
        }
    }