Validator function for validating that a value does not violate it's
    maximum allowed value.  This validation can be inclusive, or exclusive of
    the maximum depending on the value of `is_exclusive`.
340400
def validate_maximum(value, maximum, is_exclusive, **kwargs):
    
    if is_exclusive:
        comparison_text = "less than"
        compare_fn = operator.lt
    else:
        comparison_text = "less than or equal to"
        compare_fn = operator.le

    if not compare_fn(value, maximum):
        raise ValidationError(
            MESSAGES['maximum']['invalid'].format(value, comparison_text, maximum),
        )
1016356
def min_max(obj, val, is_max):
    
    n = getattr(obj, 'maximum' if is_max else 'minimum', None)
    if n == None:
        return

    _eq = getattr(obj, 'exclusiveMaximum' if is_max else 'exclusiveMinimum', False)
    if is_max:
        to_raise = val >= n if _eq else val > n
    else:
        to_raise = val <= n if _eq else val < n

    if to_raise:
        raise ValidationError('condition failed: {0}, v:{1} compared to o:{2}'.format('maximum' if is_max else 'minimum', val, n))
347445
def validate_wrap(self, value, *types):
        '''  '''
        for type in types:
            if isinstance(value, type):
                break
        else:
            self._fail_validation_type(value, *types)

        if self.min is not None and value < self.min:
            self._fail_validation(value, 'Value too small')
        if self.max is not None and value > self.max:
            self._fail_validation(value, 'Value too large')
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))
396859
private function validateLowerThan(): bool
    {
        if ($this->options['max'] !== null) {
            if ($this->options['inclusive'] === false && $this->value >= $this->options['max']) {
                $this->setError(self::VALIDATOR_ERROR_NUMBER_MUST_BE_LOWER_THAN_MAX);
                return false;
            }

            if ($this->value > $this->options['max']) {
                $this->setError(self::VALIDATOR_ERROR_NUMBER_MUST_BE_LOWER_OR_EQUAL_TO_MAX);
                return false;
            }
        }
        return true;
    }
400901
def validate_positive_float(option, value):
    
    errmsg = "%s must be an integer or float" % (option,)
    try:
        value = float(value)
    except ValueError:
        raise ValueError(errmsg)
    except TypeError:
        raise TypeError(errmsg)

    # float('inf') doesn't work in 2.4 or 2.5 on Windows, so just cap floats at
    # one billion - this is a reasonable approximation for infinity
    if not 0 < value < 1e9:
        raise ValueError("%s must be greater than 0 and "
                         "less than one billion" % (option,))
    return value
1147112
def is_valid(cls, arg):
        """"""
        if not isinstance(arg, (int, long)) or isinstance(arg, bool):
            return False
        if (arg < cls._low_limit):
            return False
        if (cls._high_limit is not None) and (arg > cls._high_limit):
            return False
        return True
37962
function check_value(val, min, max) {
    val = +val;
    if (typeof(val) != 'number' || val < min || val > max || Math.floor(val) !== val) {
        throw new TypeError("\"value\" argument is out of bounds");
    }
    return val;
}
380797
function isValidNumber(value: any): boolean {
  return typeof value === 'number' && value === value && value !== Infinity && value !== -Infinity
}
907184
def _validate_forbidden(self, forbidden_values, field, value):
        
        if isinstance(value, _str_type):
            if value in forbidden_values:
                self._error(field, errors.FORBIDDEN_VALUE, value)
        elif isinstance(value, Sequence):
            forbidden = set(value) & set(forbidden_values)
            if forbidden:
                self._error(field, errors.FORBIDDEN_VALUES, list(forbidden))
        elif isinstance(value, int):
            if value in forbidden_values:
                self._error(field, errors.FORBIDDEN_VALUE, value)
1373994
def between(min_value, max_value):
    
    def validate(value):
        if value < min_value:
            return e("{} is not greater than or equal to {}",
                value, min_value)
        if value > max_value:
            return e("{} is not less than or equal to {}",
                value, max_value)
    return validate
325642
def validate(self, value):
        
        try:
            v = int(value)
            if v not in self.allowed:
                return None
            return value
        except ValueError:
            return None
712484
def strict=(strict)
      validator = EnumAttributeValidator.new('String', ["none"])
      unless validator.valid?(strict)
        fail ArgumentError, "invalid value for 'strict', must be one of #{validator.allowable_values}."
      end
      @strict = strict
    end
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))
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
1250456
def _has_exclusive_option(cls, options):
        """"""
        return any([getattr(options, opt) is not None for opt in
                    cls.BASE_ERROR_SELECTION_OPTIONS])
1247567
def check(self, value):
        
        if self._inclusive:
            return False if self._min <= value <= self._max else True
        else:
            return False if value > self._max or value < self._min else True