def _validatePolicy(self, policy):
        """
        Validate a policy JSON object.  Only a limited set of keys is
        supported, and each of them has a restricted data type.

        :param policy: JSON object to validate.  This may also be a Python
                           dictionary as if the JSON was already decoded.
        :returns: a validate policy dictionary.
        """
        if not isinstance(policy, dict):
            try:
                policy = json.loads(policy)
            except ValueError:
                raise RestException('The policy parameter must be JSON.')
        if not isinstance(policy, dict):
            raise RestException('The policy parameter must be a dictionary.')
        validKeys = []
        for key in dir(self):
            if key.startswith('_validate_'):
                validKeys.append(key.split('_validate_', 1)[1])
        for key in list(policy):
            if key.startswith('_'):
                del policy[key]
        for key in policy:
            if key not in validKeys:
                raise RestException(
                    '%s is not a valid quota policy key.  Valid keys are '
                    '%s.' % (key, ', '.join(sorted(validKeys))))
            funcName = '_validate_' + key
            policy[key] = getattr(self, funcName)(policy[key])
        return policy
dataset/ETHPy150Open girder/girder/plugins/user_quota/server/quota.py/QuotaPolicy._validatePolicy/original