Validate any sized object to ensure the size/length
    is in a given range [min_length, max_length].
429922
def fit_size(min_length: int = 0, max_length: int = None,
             message=None) -> Filter_T:
    

    def validate(value):
        length = len(value) if value is not None else 0
        if length < min_length or \
                (max_length is not None and length > max_length):
            _raise_failure(message)
        return value

    return validate
892619
def validate(self, value: int):
        '''  '''
        if not isinstance(value, int):
            raise ValueError('value is not an integer')

        if self.minimum > value or self.maximum < value:
            msg = (
                '{} is outside the valide range [{},{}]'
            ).format(value, self.minimum, self.maximum)
            raise ValueError(msg)
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
1056771
def assert_valid(self, instance, value=None):
        """"""
        valid = super(Tuple, self).assert_valid(instance, value)
        if not valid:
            return False
        if value is None:
            value = instance._get(self.name)
            if value is None:
                return True
        if (
                (self.min_length is not None and len(value) < self.min_length)
                or
                (self.max_length is not None and len(value) > self.max_length)
        ):
            self.error(
                instance=instance,
                value=value,
                extra='(Length is {})'.format(len(value)),
            )
        for val in value:
            if not self.prop.assert_valid(instance, val):
                return False
        return True
219008
def _check_min_max_range(self, var, test_ctx):
        
        if 'valid_range' in var.ncattrs():
            test_ctx.assert_true(var.valid_range.dtype == var.dtype and
                                 len(var.valid_range) == 2
                                 and var.valid_range[0] <= var.valid_range[1],
                                 "valid_range must be a two element vector of min followed by max with the same data type as {}".format(var.name)
                                 )
        else:
            for bound in ('valid_min', 'valid_max'):
                v_bound = getattr(var, bound, '')
                warn_msg = '{} attribute should exist, have the same type as {}, and not be empty or valid_range should be defined'.format(bound, var.name)
                # need to special case str attributes since they aren't directly
                # comparable to numpy dtypes
                if isinstance(v_bound, six.string_types):
                    test_ctx.assert_true(v_bound != '' and
                                         var.dtype.char == 'S', warn_msg)
                # otherwise compare the numpy types directly
                else:
                    test_ctx.assert_true(v_bound.dtype == var.dtype, warn_msg)
        return test_ctx
325752
def check_tuple_size(tuples, tuple_size, context):
  """"""
  if tuple_size is not None and tuples.shape[1] != tuple_size:
    msg_t = (("Tuples of {} element(s) expected{}. Got tuples of {} "
             "element(s) instead (shape={}):\ninput={}.\n")
             .format(tuple_size, context, tuples.shape[1], tuples.shape,
                     tuples))
    raise ValueError(msg_t)
62783
function isValidSize(size) {
  return isArray(size) && size.length === 2 && isInteger(size[0]) && isInteger(size[1]);
}
153051
def validate_work_spec(cls, work_spec):
        '''

        '''
        if 'name' not in work_spec:
            raise ProgrammerError('work_spec lacks "name"')
        if 'min_gb' not in work_spec or \
                not isinstance(work_spec['min_gb'], (float, int, long)):
            raise ProgrammerError('work_spec["min_gb"] must be a number')
767966
def validate(self, value):
        
        # check object type
        if not isinstance(value, list):
            raise tldap.exceptions.ValidationError(
                "is not a list and max_instances is %s" %
                self._max_instances)
        # check maximum instances
        if (self._max_instances is not None and
                len(value) > self._max_instances):
            raise tldap.exceptions.ValidationError(
                "exceeds max_instances of %d" %
                self._max_instances)
        # check this required value is given
        if self._required:
            if len(value) == 0:
                raise tldap.exceptions.ValidationError(
                    "is required")
        # validate the value
        for i, v in enumerate(value):
            self.value_validate(v)
1285947
def _validate(self, val):
        
        if self.allow_None and val is None:
            return

        if not isinstance(val, list):
            raise ValueError("List '%s' must be a list."%(self.name))

        if self.bounds is not None:
            min_length,max_length = self.bounds
            l=len(val)
            if min_length is not None and max_length is not None:
                if not (min_length <= l <= max_length):
                    raise ValueError("%s: list length must be between %s and %s (inclusive)"%(self.name,min_length,max_length))
            elif min_length is not None:
                if not min_length <= l:
                    raise ValueError("%s: list length must be at least %s."%(self.name,min_length))
            elif max_length is not None:
                if not l <= max_length:
                    raise ValueError("%s: list length must be at most %s."%(self.name,max_length))

        self._check_type(val)
202882
def maybe_set_size(self, min_itemsize=None):
        
        if _ensure_decoded(self.kind) == 'string':

            if isinstance(min_itemsize, dict):
                min_itemsize = min_itemsize.get(self.name)

            if min_itemsize is not None and self.typ.itemsize < min_itemsize:
                self.typ = _tables(
                ).StringCol(itemsize=min_itemsize, pos=self.pos)
1020256
def _validate_min(self, proposal):
        """"""
        min = proposal['value']
        if min > self.max:
            raise TraitError('Setting min > max')
        if min > self.value:
            self.value = min
        return min
585676
def _parse_size(self, size, has_time=False):
        """"""
        if has_time:
            size = size or 4
        else:
            size = size or 10
        if isinstance(size, str):
            size = {'column': size}
        if isinstance(size, dict):
            if 'column' not in size:
                raise ValueError("`size` must include a 'column' key/value")
            if has_time:
                raise ValueError("When time is specified, size can "
                                 "only be a fixed size")
            old_size = size
            # Default size range, bins, and bin_method
            size = {
                'range': [5, 25],
                'bins': 5,
                'bin_method': BinMethod.quantiles,
            }
            # Assign default range and update if min/max given
            old_size['range'] = old_size.get('range', size['range'])
            if 'min' in old_size:
                old_size['range'][0] = old_size['min']
                old_size.pop('min')
            if 'max' in old_size:
                old_size['range'][1] = old_size['max']
                old_size.pop('max')
            # Update all the keys in size if they exist in old_size
            size.update(old_size)
            self.style_cols[size['column']] = None

        return size
751764
def _check_len(a, b):
    
    if len(a) != len(b):
        msg = "Length must be {}. Got {}".format(len(a), len(b))
        raise ValueError(msg)
628498
function validateLength(attr, conf, err) {
    if (nullCheck.call(this, attr, conf, err)) return;

    var len = this[attr].length;
    if (conf.min && len < conf.min) {
        err('min');
    }
    if (conf.max && len > conf.max) {
        err('max');
    }
    if (conf.is && len !== conf.is) {
        err('is');
    }
}
1148676
def _maxSizeCheck(cls, obj):
        
        fail = False
        size = 0

        if isinstance(obj, numbers.Number):
            if obj > constants.MAX_FRAME_SIZE:
                fail = True
                size = obj

        elif hasattr(obj, '__len__'):
            size = len(obj)
            fail = size > constants.MAX_FRAME_SIZE

        if fail:
            raise MaxSizeException('Frame size %s > %s (MAX_FRAME_SIZE)' \
                    % (size, constants.MAX_FRAME_SIZE))
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