# Path: girlfriend/util/lang.py
# def args2fields(private=True):
#     """专门是应用于构造函数的修饰器
#        可以将构造函数除self以外的参数悉数赋值给类属性
# 
#        比如
# 
#        class A(object):
# 
#             def __init__(self, a, b, c):
#                 self._a = a
#                 self._b = b
#                 self._c = c
#                 self.sum = self._a + self._b + self._c
# 
#         只要写成这样就好:
# 
#         class A(object):
# 
#             @args2fields()
#             def __init__(self, a, b, c):
#                 self.sum = self._a + self._b + self._c
# 
#         不必再去写上面那些无聊的赋值语句了
# 
#         :param private 是否转变为私有字段，如果为True，那么会在所有字段名前加个下划线
#     """
# 
#     def _field_name(arg_name):
#         return "_" + arg_name if private else arg_name
# 
#     def _args2fields(constructor):
# 
#         @wraps(constructor)
#         def _wrapped_constuctor(self, *args, **kws):
#             args_spec = inspect.getargspec(constructor)
#             for idx, arg in enumerate(args, start=1):
#                 arg_name = args_spec.args[idx]
#                 field_name = _field_name(arg_name)
#                 setattr(self, field_name, arg)
#             for arg_name, arg in kws.items():
#                 field_name = _field_name(arg_name)
#                 setattr(self, field_name, arg)
# 
#             # 处理没有赋值的默认参数
#             default_args = get_default_args(args_spec)
#             if default_args:
#                 for arg_name, default_value in default_args.items():
#                     if arg_name == "self":
#                         continue
#                     field_name = _field_name(arg_name)
#                     if hasattr(self, field_name):
#                         continue
#                     setattr(self, field_name, default_value)
# 
#             constructor(self, *args, **kws)
# 
#         return _wrapped_constuctor
# 
#     return _args2fields
# 
# Path: girlfriend/exception.py
# class InvalidArgumentException(GirlFriendSysException):
# 
#     """当函数输入的参数不正确时抛出此异常
#     """
#     pass


import re
import ujson
import types
import numbers
from girlfriend.util.lang import args2fields
from girlfriend.exception import InvalidArgumentException
                if self._min > value:
                    raise InvalidArgumentException(
                        u"参数 '{name}' 的值不能小于{min}".format(
                            name=self._name, min=self._min)
                    )
            else:
                if self._min > len(value):
                    raise InvalidArgumentException(
                        u"参数 '{name}' 的长度不能小于{min}".format(
                            name=self._name, min=self._min)
                    )
        if self._max is not None:
            if isinstance(value, numbers.Number):
                if self._max < value:
                    raise InvalidArgumentException(
                        u"参数 '{name}' 的值不能大于{max}".format(
                            name=self._name, max=self._max)
                    )
            else:
                if self._max < len(value):
                    raise InvalidArgumentException(
                        u"参数 '{name}' 的长度不能大于{max}".format(
                            name=self._name, max=self._max)
                    )

    def _validate_regex(self, value):
        if not self._regex:
            return
        value = str(value)
        if not re.search(self._regex, value):

# Path: girlfriend/util/lang.py
# def args2fields(private=True):
#     """专门是应用于构造函数的修饰器
#        可以将构造函数除self以外的参数悉数赋值给类属性
# 
#        比如
# 
#        class A(object):
# 
#             def __init__(self, a, b, c):
#                 self._a = a
#                 self._b = b
#                 self._c = c
#                 self.sum = self._a + self._b + self._c
# 
#         只要写成这样就好:
# 
#         class A(object):
# 
#             @args2fields()
#             def __init__(self, a, b, c):
#                 self.sum = self._a + self._b + self._c
# 
#         不必再去写上面那些无聊的赋值语句了
# 
#         :param private 是否转变为私有字段，如果为True，那么会在所有字段名前加个下划线
#     """
# 
#     def _field_name(arg_name):
#         return "_" + arg_name if private else arg_name
# 
#     def _args2fields(constructor):
# 
#         @wraps(constructor)
#         def _wrapped_constuctor(self, *args, **kws):
#             args_spec = inspect.getargspec(constructor)
#             for idx, arg in enumerate(args, start=1):
#                 arg_name = args_spec.args[idx]
#                 field_name = _field_name(arg_name)
#                 setattr(self, field_name, arg)
#             for arg_name, arg in kws.items():
#                 field_name = _field_name(arg_name)
#                 setattr(self, field_name, arg)
# 
#             # 处理没有赋值的默认参数
#             default_args = get_default_args(args_spec)
#             if default_args:
#                 for arg_name, default_value in default_args.items():
#                     if arg_name == "self":
#                         continue
#                     field_name = _field_name(arg_name)
#                     if hasattr(self, field_name):
#                         continue
#                     setattr(self, field_name, default_value)
# 
#             constructor(self, *args, **kws)
# 
#         return _wrapped_constuctor
# 
#     return _args2fields
# 
# Path: girlfriend/exception.py
# class InvalidArgumentException(GirlFriendSysException):
# 
#     """当函数输入的参数不正确时抛出此异常
#     """
#     pass


# Path: girlfriend/util/validating.py
import re
import ujson
import types
import numbers
from girlfriend.util.lang import args2fields
from girlfriend.exception import InvalidArgumentException

                if self._min > value:
                    raise InvalidArgumentException(
                        u"参数 '{name}' 的值不能小于{min}".format(
                            name=self._name, min=self._min)
                    )
            else:
                if self._min > len(value):
                    raise InvalidArgumentException(
                        u"参数 '{name}' 的长度不能小于{min}".format(
                            name=self._name, min=self._min)
                    )
        if self._max is not None:
            if isinstance(value, numbers.Number):
                if self._max < value:
                    raise InvalidArgumentException(
                        u"参数 '{name}' 的值不能大于{max}".format(
                            name=self._name, max=self._max)
                    )
            else:
                if self._max < len(value):
                    raise InvalidArgumentException(
                        u"参数 '{name}' 的长度不能大于{max}".format(
                            name=self._name, max=self._max)
                    )

    def _validate_regex(self, value):
        if not self._regex:
            return
        value = str(value)
        if not re.search(self._regex, value):

            raise InvalidArgumentException(