Reuse standard integer validator but add checks on sign and zero.
359866
def convert(self, value, param, ctx):
        
        value = super(PositiveInt, self).convert(value, param, ctx)
        if value < 0:
            self.fail('%s is not positive' % value, param, ctx)
        if not self.allow_zero and not value:
            self.fail('%s is not greater than 0' % value, param, ctx)
        return value
874141
def _validate_timeout(timeout, infinity_ok=False):
    
    if timeout is None:
        return

    if timeout == 'infinity':
        if infinity_ok:
            return
        else:
            raise ValueError(
                'timeout must be a positive integer '
                '("infinity" is not valid)')

    if isinstance(timeout, six.integer_types) and timeout > 0:
        return

    raise ValueError('timeout must be a positive integer')
307003
def value_validate(self, value):
        
        if not isinstance(value, str):
            raise tldap.exceptions.ValidationError("Invalid sid")

        array = value.split("-")
        length = len(array) - 3

        if length < 1:
            raise tldap.exceptions.ValidationError("Invalid sid")

        if array.pop(0) != "S":
            raise tldap.exceptions.ValidationError("Invalid sid")

        try:
            [int(i) for i in array]
        except TypeError:
            raise tldap.exceptions.ValidationError("Invalid sid")
885556
def validate_non_negative_integer(option, value):
    
    val = validate_integer(option, value)
    if val < 0:
        raise ValueError("The value of %s must be "
                         "a non negative integer" % (option,))
    return val
344645
def _check_negatives(numbers):
    ""

    negatives = filter(lambda x: x < 0, filter(None, numbers))
    if any(negatives):
        neg_values = ', '.join(map(str, negatives))
        msg = 'Found negative value(s): {0!s}. '.format(neg_values)
        msg += 'While not forbidden, the output will look unexpected.'
        warnings.warn(msg)
458421
def clean(self, value):
        """"""

        if isinstance(value, numbers.Number):
            return value
        elif isinstance(value, six.string_types):
            try:
                value = float(value)
                return int(value) if value.is_integer() else value
            except ValueError:
                raise ParameterNotValidError

        raise ParameterNotValidError
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
1000071
def _validate(self, p):
        
        if self._is_operator(p):
            for operator_or_filter in (p[1] if p[0] != '!' else [p[1]]):
                if p[0] == '^':
                    self._validate_xor_args(p)
                self._validate(operator_or_filter)
        elif not self._is_value_filter(p) and not self._is_key_filter(p):
            raise ValueError('Not a valid operator or filter - {0}'.format(p))
1144202
def is_valid_int(value):
        """"""
        if 0 <= value <= Parameter.MAX:  # This includes ON and OFF
            return True
        if value == Parameter.UNKNOWN_VALUE:
            return True
        if value == Parameter.CURRENT_POSITION:
            return True
        return False
62925
function intValidatorNoErrors( n, min, max ) {
        return ( n = truncate(n) ) >= min && n <= max;
    }
781587
def validate(self,value):
        """"""
        if self.validator is not None:
            try:
                valid = self.validator(value)
            except Exception as e:
                import pdb; pdb.set_trace()
            if isinstance(valid, tuple) and len(valid) == 2:
                valid, errormsg = valid
            elif isinstance(valid, bool):
                errormsg = "Invalid value"
            else:
                raise TypeError("Custom validator must return a boolean or a (bool, errormsg) tuple.")
            if valid:
                self.error = None
            else:
                self.error = errormsg
            return valid
        else:
            self.error = None #reset error
            return True
76555
def with_validator(self, validator):
    """"""
    if not callable(validator):
      raise ValueError('Validator must be callable', validator)
    self.validators.append(validator)
    self._cached = None
    return self
500159
def validate(self, tracking_number):
        ""
        tracking_num = tracking_number[2:-1]
        odd_total = 0
        even_total = 0

        for ii, digit in enumerate(tracking_num.upper()):
            try:
                value = int(digit)
            except ValueError:
                value = int((ord(digit) - 63) % 10)
            if (ii + 1) % 2:
                odd_total += value
            else:
                even_total += value

        total = odd_total + even_total * 2
        check = ((total - (total % 10) + 10) - total) % 10
        return (check == int(tracking_number[-1:]))
1050604
def validate(cls, cnd):
        ""
        if cnd not in cls.VALUES:
            raise ValueError("Value {} cannot be used in {}".format(
                cnd, cls
            ))
        return cls(cnd)
876584
def validate(self):
        """"""
        _validate_operator_name(self.operator, BinaryComposition.SUPPORTED_OPERATORS)

        if not isinstance(self.left, Expression):
            raise TypeError(u'Expected Expression left, got: {} {} {}'.format(
                type(self.left).__name__, self.left, self))

        if not isinstance(self.right, Expression):
            raise TypeError(u'Expected Expression right, got: {} {}'.format(
                type(self.right).__name__, self.right))
51543
def check_int(integer):
    
    if not isinstance(integer, str):
        return False
    if integer[0] in ('-', '+'):
        return integer[1:].isdigit()
    return integer.isdigit()
1052176
def signedVarintSize(value):
  """"""
  if value < 0: return 10
  if value <= 0x7f: return 1
  if value <= 0x3fff: return 2
  if value <= 0x1fffff: return 3
  if value <= 0xfffffff: return 4
  if value <= 0x7ffffffff: return 5
  if value <= 0x3ffffffffff: return 6
  if value <= 0x1ffffffffffff: return 7
  if value <= 0xffffffffffffff: return 8
  if value <= 0x7fffffffffffffff: return 9
  return 10