code: 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
docs: Build a validator that checks the return value of function(data).