Creates a validator that checks if the given value's length is in the
    specified range, inclusive. (Returns the original value.)

    See :func:`.Range`.
341811
def Length(min=None, max=None, min_message="Must have a length of at least {min}", max_message="Must have a length of at most {max}"):
    
    validator = Range(min, max, min_message, max_message)
    @wraps(Length)
    def built(value):
        if not hasattr(value, '__len__'):
            raise Error("Does not have a length")
        validator(len(value))
        return value
    return built
1104922
def validate(self, instance, value):
        """"""

        value = super(BaseVector, self).validate(instance, value)

        if self.length is not None:
            try:
                value.length = self._length_array(value)
            except ZeroDivisionError:
                self.error(
                    instance, value,
                    error_class=ZeroDivValidationError,
                    extra='The vector must have a length specified.'
                )
        return value
917294
function (value, min, max) {
        min = min | 0;
        let length = ((value || '') + '').length;
        if (length < min) {
            return false;
        }
        if (max && length > max) {
            return false;
        }
        return true;
    }
1014097
function range(start, length) {
      var rgArr = [];
      if (isNum(start)) {
        function rangeLoop(isAdd) {
          if (length >= 0) {
            for (var i = 0; i < length; i++) rgArr.push(isAdd ? i + start : i);
          } else if (length < 0) {
            for (var i = 0; i > length; i--) rgArr.push(isAdd ? i + start : i);
          }
        };
        if (isUdf(length)) {
          length = start, start = UDF;
          rangeLoop(false);
        } else if (isNum(length)) {
          rangeLoop(true);
        }
      }
      return rgArr;
    }
267344
def _validate_datetime(cls, value):
        
        datetime_check = validators.Int()
        datetime_check.to_python(value)
        if len(value) != 8:
            raise MlbAmBadParameter("Length Error:{value}({length})".format(value=value, length=len(value)))
560777
def validate(self, instance, value):
        
        try:
            compval = complex(value)
            if not self.cast and (
                    abs(value.real - compval.real) > TOL or
                    abs(value.imag - compval.imag) > TOL
            ):
                self.error(
                    instance=instance,
                    value=value,
                    extra='Not within tolerance range of {}.'.format(TOL),
                )
        except (TypeError, ValueError, AttributeError):
            self.error(instance, value)
        return compval
425021
public static boolean inRange(Range range, double val) {
        return val >= range.min() && val <= range.max();
    }
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
  };
}
993800
public static int checkBetween(int value, int min, int max) {
		if (value < min || value > max) {
			throw new IllegalArgumentException(StrUtil.format("Length must be between {} and {}.", min, max));
		}
		return value;
	}
387929
def _validate_slice(self, start, end):
        """"""
        if start is None:
            start = 0
        elif start < 0:
            start += self.len
        if end is None:
            end = self.len
        elif end < 0:
            end += self.len
        if not 0 <= end <= self.len:
            raise ValueError("end is not a valid position in the bitstring.")
        if not 0 <= start <= self.len:
            raise ValueError("start is not a valid position in the bitstring.")
        if end < start:
            raise ValueError("end must not be less than start.")
        return start, end
1032182
function range(defaultMin, defaultMax, min, max) {
  if (min === undefined) {
    return integer(defaultMin, defaultMax); // ()
  }

  if (max === undefined) {
    return min; // ( len )
  }

  return integer(min, max); // ( min, max )
}
462295
def _validate(self, val):
        
        if not self.check_on_set:
            self._ensure_value_is_in_objects(val)
            return

        if not (val in self.objects or (self.allow_None and val is None)):
            # CEBALERT: can be called before __init__ has called
            # super's __init__, i.e. before attrib_name has been set.
            try:
                attrib_name = self.name
            except AttributeError:
                attrib_name = ""

            items = []
            limiter = ']'
            length = 0
            for item in self.objects:
                string = str(item)
                length += len(string)
                if length < 200:
                    items.append(string)
                else:
                    limiter = ', ...]'
                    break
            items = '[' + ', '.join(items) + limiter
            raise ValueError("%s not in Parameter %s's list of possible objects, "
                             "valid options include %s"%(val,attrib_name, items))
345143
def validate(self, value):
        
        try:
            int_value = int(value)
            self._choice = int_value
            return True
        except ValueError:
            self.error_message = '%s is not a valid integer.' % value
            return False
886709
def _validate_maxlength(self, max_length, field, value):
        
        if isinstance(value, Iterable) and len(value) > max_length:
            self._error(field, errors.MAX_LENGTH, len(value))
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);
        }
    }
961546
def validate(self, value):
        
        try:
            # trap blank fields here
            if not self.blank or value:
                v = int(value)
                if v < 0:
                    return None
            return value
        except ValueError:
            return None
1330190
def validate_INCREASING(in_value, restriction):
    

    flat_list = _flatten_value(in_value)

    previous = None
    for a in flat_list:
        if previous is None:
            previous = a
            continue
        try:
            if a < previous:
                raise ValidationError("INCREASING")
        except TypeError:
            raise  ValueError("INCREASING: Incompatible types")
        previous = a