# Path: pale/errors/validation.py
# class ArgumentError(BasePaleError):
#     def __init__(self, arg_name, message):
#         error_msg = ("Invalid argument: `%s`.  %s"
#                 % (arg_name, message))
#         self.arg_name = arg_name
#         super(ArgumentError, self).__init__(error_msg)
# 
# Path: pale/arguments/base.py
# class BaseArgument(BaseField):
#     """The base class for Pale Arguments.
# 
#     Arguments in this context are values passed in to Pale Endpoints from the
#     HTTP layer.  These Argument objects are expected to validate parameters
#     received from the HTTP layer before they're propagated to the endpoint
#     handler that you define in your API.
# 
#     The `validate` method in subclasses should return the value if it is
#     valid (including returning None if None is a valid value), or raise an
#     ArgumentError if the argument is invalid.
# 
#     The ArgumentError will generate an HTTP 422 Unprocessable Entity response,
#     and propagate the message of the exception to the caller.
#     """
#     allowed_types = (object,)
# 
#     def __init__(self,
#             short_doc,
#             default=None,
#             required=False,
#             **kwargs):
#         """Initialize an argument.
# 
#         This method is usually called from the Endpoint definition, and the
#         created object is typically assigned to a key in the endpoint's
#         `arguments` dictionary.
#         """
#         self.description = short_doc
#         self.default = default
#         self.required = required
#         for k, v in kwargs.iteritems():
#             setattr(self, k, v)
# 
# 
#     def validate(self, item, item_name):
#         """Validate the passed in item.
# 
#         The `item_name` is passed in so that we can generate a human-readable
#         and user friendly error message, but this is architecturally a bit
#         cumbersome right now, so we may want to change it in the future.
# 
#         Subclasses of BaseArgument should implement their own validation
#         function.
#         """
#         raise ArgumentError(item_name,
#                 ("ERROR! Your endpoint is missing a parser for your argument. "
#                  "The argument validator bubbled all the way up to the base "
#                  "argument, which is definitely not what you want!"))
# 
# 
#     def _validate_type(self, item, name):
#         """Validate the item against `allowed_types`."""
#         if item is None:
#             # don't validate None items, since they'll be caught by the portion
#             # of the validator responsible for handling `required`ness
#             return
# 
#         if not isinstance(item, self.allowed_types):
#             item_class_name = item.__class__.__name__
#             raise ArgumentError(name,
#                 "Expected one of %s, but got `%s`" % (
#                     self.allowed_types, item_class_name))
# 
# 
#     def _validate_required(self, item, name):
#         """Validate that the item is present if it's required."""
#         if self.required is True and item is None:
#             raise ArgumentError(name, "This argument is required.")
# 
# 
#     def doc_dict(self):
#         """Returns the documentation dictionary for this argument."""
#         doc = {
#             'type': self.__class__.__name__,
#             'description': self.description,
#             'default': self.default,
#             'required': self.required
#         }
#         if hasattr(self, 'details'):
#             doc['detailed_description'] = self.details
#         return doc


from pale.errors.validation import ArgumentError
from .base import BaseArgument
                    "%s is not a valid integer" % item)

        # range checking
        if self.min_value is not None and\
                self.max_value is not None and\
                not (self.min_value <= item <= self.max_value):
            raise ArgumentError(item_name,
                    "You must provide a value between %d and %d" % (
                        self.min_value, self.max_value))

        if self.min_value is not None and item < self.min_value:
            raise ArgumentError(item_name,
                    "You must provide a value greater than or equal to %d" % (
                        self.min_value))

        if self.max_value is not None and item > self.max_value:
            raise ArgumentError(item_name,
                    "You must provide a value less than or equal to %d" % (
                        self.max_value))

        return item


    def doc_dict(self):
        doc = super(IntegerArgument, self).doc_dict()
        doc['min_value'] = self.min_value
        doc['max_value'] = self.max_value
        return doc



# Path: pale/errors/validation.py
# class ArgumentError(BasePaleError):
#     def __init__(self, arg_name, message):
#         error_msg = ("Invalid argument: `%s`.  %s"
#                 % (arg_name, message))
#         self.arg_name = arg_name
#         super(ArgumentError, self).__init__(error_msg)
# 
# Path: pale/arguments/base.py
# class BaseArgument(BaseField):
#     """The base class for Pale Arguments.
# 
#     Arguments in this context are values passed in to Pale Endpoints from the
#     HTTP layer.  These Argument objects are expected to validate parameters
#     received from the HTTP layer before they're propagated to the endpoint
#     handler that you define in your API.
# 
#     The `validate` method in subclasses should return the value if it is
#     valid (including returning None if None is a valid value), or raise an
#     ArgumentError if the argument is invalid.
# 
#     The ArgumentError will generate an HTTP 422 Unprocessable Entity response,
#     and propagate the message of the exception to the caller.
#     """
#     allowed_types = (object,)
# 
#     def __init__(self,
#             short_doc,
#             default=None,
#             required=False,
#             **kwargs):
#         """Initialize an argument.
# 
#         This method is usually called from the Endpoint definition, and the
#         created object is typically assigned to a key in the endpoint's
#         `arguments` dictionary.
#         """
#         self.description = short_doc
#         self.default = default
#         self.required = required
#         for k, v in kwargs.iteritems():
#             setattr(self, k, v)
# 
# 
#     def validate(self, item, item_name):
#         """Validate the passed in item.
# 
#         The `item_name` is passed in so that we can generate a human-readable
#         and user friendly error message, but this is architecturally a bit
#         cumbersome right now, so we may want to change it in the future.
# 
#         Subclasses of BaseArgument should implement their own validation
#         function.
#         """
#         raise ArgumentError(item_name,
#                 ("ERROR! Your endpoint is missing a parser for your argument. "
#                  "The argument validator bubbled all the way up to the base "
#                  "argument, which is definitely not what you want!"))
# 
# 
#     def _validate_type(self, item, name):
#         """Validate the item against `allowed_types`."""
#         if item is None:
#             # don't validate None items, since they'll be caught by the portion
#             # of the validator responsible for handling `required`ness
#             return
# 
#         if not isinstance(item, self.allowed_types):
#             item_class_name = item.__class__.__name__
#             raise ArgumentError(name,
#                 "Expected one of %s, but got `%s`" % (
#                     self.allowed_types, item_class_name))
# 
# 
#     def _validate_required(self, item, name):
#         """Validate that the item is present if it's required."""
#         if self.required is True and item is None:
#             raise ArgumentError(name, "This argument is required.")
# 
# 
#     def doc_dict(self):
#         """Returns the documentation dictionary for this argument."""
#         doc = {
#             'type': self.__class__.__name__,
#             'description': self.description,
#             'default': self.default,
#             'required': self.required
#         }
#         if hasattr(self, 'details'):
#             doc['detailed_description'] = self.details
#         return doc


# Path: pale/arguments/number.py
from pale.errors.validation import ArgumentError
from .base import BaseArgument

                    "%s is not a valid integer" % item)

        # range checking
        if self.min_value is not None and\
                self.max_value is not None and\
                not (self.min_value <= item <= self.max_value):
            raise ArgumentError(item_name,
                    "You must provide a value between %d and %d" % (
                        self.min_value, self.max_value))

        if self.min_value is not None and item < self.min_value:
            raise ArgumentError(item_name,
                    "You must provide a value greater than or equal to %d" % (
                        self.min_value))

        if self.max_value is not None and item > self.max_value:
            raise ArgumentError(item_name,
                    "You must provide a value less than or equal to %d" % (
                        self.max_value))

        return item


    def doc_dict(self):
        doc = super(IntegerArgument, self).doc_dict()
        doc['min_value'] = self.min_value
        doc['max_value'] = self.max_value
        return doc



class FloatArgument(BaseArgument):