Creates a validator chain from several validator functions.

    :param chained_validators:
    :type chained_validators:
    :return:
    :rtype:
320524
def validators(*chained_validators):
    
    def validator_chain(match):  # pylint:disable=missing-docstring
        for chained_validator in chained_validators:
            if not chained_validator(match):
                return False
        return True
    return validator_chain
204543
def _run_validators(self, value):
        
        errors = []
        for v in self.validators:
            try:
                v(value)
            except ValidationError, e:
                errors.extend(e.messages)
        if errors:
            raise ValidationError(errors)
955367
def stringmethod(func):
    
    method_name = func()

    @wraps(func)
    def factory():
        def validator(v):
            if not isinstance(v, six.string_types):
                raise Invalid(_(u'Not a string'), get_type_name(six.text_type), get_type_name(type(v)))
            return getattr(v, method_name)()
        return validator
    return factory
1358228
def All(*validators):
    
    @wraps(All)
    def built(value):
        for validator in validators:
            value = validator(value)
        return value
    return built
1089204
def build_cert_chain(self, flags=SSL_BUILD_CHAIN_FLAG_NONE):
        
        '''
        retVal = SSL_CTX_build_cert_chain(self._ctx, flags)
        return retVal
299889
def validate(func):
    
    call = PythonCall(func)

    @wraps(func)
    def decorator(*args, **kwargs):
        parameters = call.bind(args, kwargs)
        for arg_name, validator in func.__annotations__.items():
            if not validator(parameters[arg_name]):
                raise TypeError(
                    "Argument {!r} failed to validate".format(arg_name))
        return call.apply(args, kwargs)
    return decorator
597576
function createChainedFunction(one, two) {
  var hasOne = typeof one === 'function';
  var hasTwo = typeof two === 'function';

  if (!hasOne && !hasTwo) {return null;}
  if (!hasOne) {return two;}
  if (!hasTwo) {return one;}

  return function chainedFunction() {
    one.apply(this, arguments);
    two.apply(this, arguments);
  };
}
885780
def generate_func_code(self):
        
        self.l('NoneType = type(None)')
        # Generate parts that are referenced and not yet generated
        while self._needed_validation_functions:
            # During generation of validation function, could be needed to generate
            # new one that is added again to `_needed_validation_functions`.
            # Therefore usage of while instead of for loop.
            uri, name = self._needed_validation_functions.popitem()
            self.generate_validation_function(uri, name)
1063895
def _build_iterable_validator(iterable):
    """"""
    sub_schemas = [parse_schema(s) for s in iterable]

    def item_validator(value):
        """Validate items in an iterable."""
        for sub in sub_schemas:
            try:
                return sub(value)

            except NotValid:
                pass

        raise NotValid('%r invalidated by anything in %s.' % (value, iterable))

    def iterable_validator(data):
        """Validate an iterable."""
        if not type(data) is type(iterable):
            raise NotValid('%r is not of type %s' % (data, type(iterable)))

        return type(iterable)(item_validator(value) for value in data)

    return iterable_validator
728412
def _build_callable_validator(function):
    """"""

    def callable_validator(data):
        """Validate by checking the return value of function(data)."""
        try:
            if function(data):
                return data

        except (TypeError, ValueError, NotValid) as ex:
            raise NotValid(ex.args)

        raise NotValid("%r invalidated by '%s'" % (data, _get_repr(function)))

    return callable_validator
290749
def get_validators(cls, bigchain, height=None):
        
        validators = {}
        for validator in bigchain.get_validators(height):
            # NOTE: we assume that Tendermint encodes public key in base64
            public_key = public_key_from_ed25519_key(key_from_base64(validator['public_key']['value']))
            validators[public_key] = validator['voting_power']

        return validators
143179
def required_validator(validator, req, instance, schema):
    
    if schema.get('paramType'):
        if req is True and not instance:
            return [ValidationError("%s is required" % schema['name'])]
        return []
    return _validators.required_draft4(validator, req, instance, schema)
1165530
def build_chain(self, **kwargs):
        
        set_defaults(self._chain_defaults, kwargs)
        set_defaults(self._defaults, kwargs)
        return Chain(self, **kwargs)
101645
def extend(validator_cls):
    

    Validator = jsonschema.validators.extend(
        validator_cls, {
            "properties": _properties_with_defaults(validator_cls),
        }
    )

    class Blueprinter(Validator):
        def instantiate(self, data):
            self.validate(data)
            return data

    return Blueprinter
1348157
def run_validators(self, value):
        """"""
        errors = []
        for validator in self.validators:
            try:
                validator(value)
            except ValidationError as error:
                errors.extend(error.messages)
        if errors:
            raise ValidationError(errors)
744478
def validate(self, bigchain, current_transactions=[]):
        

        current_validators = self.get_validators(bigchain)

        super(ValidatorElection, self).validate(bigchain, current_transactions=current_transactions)

        # NOTE: change more than 1/3 of the current power is not allowed
        if self.asset['data']['power'] >= (1/3)*sum(current_validators.values()):
            raise InvalidPowerChange('`power` change must be less than 1/3 of total power')

        return self
350562
def and_(*validators):
    
    vals = []
    for validator in validators:
        vals.extend(
            validator._validators
            if isinstance(validator, _AndValidator)
            else [validator]
        )

    return _AndValidator(tuple(vals))