Exemplo n.º 1
0
 def validate(value):
     try:
         json.dumps(value)
     except TypeError:
         raise api_exception.ParameterException(('%s is not JSON serializable') % value)
     else:
         return value
Exemplo n.º 2
0
    def validate(value):
        """Validate and convert the input to a ListType.

        :param value: A comma separated string of values
        :returns: A list of unique values (lower-cased), maintaining the
                  same order
        """
        if isinstance(value, list):
            return value
        else:
            raise api_exception.ParameterException(msg='应该传数组类型')
Exemplo n.º 3
0
 def validate(value):
     try:
         return strutils.bool_from_string(value, strict=True)
     except ValueError as e:
         # raise Invalid to return 400 (BadRequest) in the API
         raise api_exception.ParameterException(six.text_type(e))
Exemplo n.º 4
0
 def validate(value):
     if not uuidutils.is_uuid_like(value):
         raise api_exception.ParameterException()
     return value