Ensure a user-account objects' 'account-type' property is from the
    account-type-ov vocabulary.
329927
def vocab_account_type(instance):
    
    for key, obj in instance['objects'].items():
        if 'type' in obj and obj['type'] == 'user-account':
            try:
                acct_type = obj['account_type']
            except KeyError:
                continue
            if acct_type not in enums.ACCOUNT_TYPE_OV:
                yield JSONError("Object '%s' is a User Account Object "
                                "with an 'account_type' of '%s', which is not a "
                                "value in the account-type-ov vocabulary."
                                % (key, acct_type), instance['id'], 'account-type')
121879
def get(account):
        
        account = Account.get(account)
        if not account:
            return None

        acct_type = AccountType.get(account.account_type_id).account_type
        account_class = get_plugin_by_name(PLUGIN_NAMESPACES['accounts'], acct_type)

        return account_class(account)
1040725
def clean_account(self):
        """"""
        account = self.cleaned_data['account']
        if not account:
            return

        if account.type != Account.TYPES.income:
            raise ValidationError('Account must be an income account')

        try:
            account.housemate
        except Housemate.DoesNotExist:
            pass
        else:
            raise ValidationError('Account already has a housemate')

        return account
148482
def from_signed_raw(cls: Type[MembershipType], signed_raw: str) -> MembershipType:
        
        lines = signed_raw.splitlines(True)
        n = 0

        version = int(Membership.parse_field("Version", lines[n]))
        n += 1

        Membership.parse_field("Type", lines[n])
        n += 1

        currency = Membership.parse_field("Currency", lines[n])
        n += 1

        issuer = Membership.parse_field("Issuer", lines[n])
        n += 1

        membership_ts = BlockUID.from_str(Membership.parse_field("Block", lines[n]))
        n += 1

        membership_type = Membership.parse_field("Membership", lines[n])
        n += 1

        uid = Membership.parse_field("UserID", lines[n])
        n += 1

        identity_ts = BlockUID.from_str(Membership.parse_field("CertTS", lines[n]))
        n += 1

        signature = Membership.parse_field("Signature", lines[n])
        n += 1

        return cls(version, currency, issuer, membership_ts,
                   membership_type, uid, identity_ts, signature)
920098
function checkType(obj, keyName) {
  return obj && typeof obj === 'object' && Object.keys(obj).length === 1 &&
    obj.hasOwnProperty(keyName);
}
179803
def get_account_db_class(cls) -> Type[BaseAccountDB]:
        
        if cls.account_db_class is None:
            raise AttributeError("No account_db_class set for {0}".format(cls.__name__))
        return cls.account_db_class
1109618
def custom_observable_object_prefix_strict(instance):
    
    for key, obj in instance['objects'].items():
        if ('type' in obj and obj['type'] not in enums.OBSERVABLE_TYPES and
                obj['type'] not in enums.OBSERVABLE_RESERVED_OBJECTS and
                not CUSTOM_TYPE_PREFIX_RE.match(obj['type'])):
            yield JSONError("Custom Observable Object type '%s' should start "
                            "with 'x-' followed by a source unique identifier "
                            "(like a domain name with dots replaced by "
                            "hyphens), a hyphen and then the name."
                            % obj['type'], instance['id'],
                            'custom-prefix')
180695
def _ensure_object_manipulation_allowed(self):
        # type: (StorageAccount) -> bool
        
        if self.is_sas:
            # search for account sas "o" resource
            sasparts = self.key.split('&')
            for part in sasparts:
                tmp = part.split('=')
                if tmp[0] == 'srt':
                    return 'o' in tmp[1]
            # this is a sas without the srt parameter, so this must be
            # a service-level sas which always allows object manipulation
            return True
        else:
            # storage account key always allows object manipulation
            return True
621299
def _validate_default_privileges(object_type, defprivs, defprivileges):
    '''
    
    '''
    if object_type != 'group':
        _defperms = [_DEFAULT_PRIVILEGES_MAP[defperm]
                for defperm in _DEFAULT_PRIVILEGE_TYPE_MAP[object_type]]
        _defperms.append('ALL')

        if object_type not in _DEFAULT_PRIVILEGES_OBJECTS:
            raise SaltInvocationError(
                'Invalid object_type: {0} provided'.format(object_type))

        if not set(defprivs).issubset(set(_defperms)):
            raise SaltInvocationError(
                'Invalid default privilege(s): {0} provided for object {1}'.format(
                defprivileges, object_type))
    else:
        if defprivileges:
            raise SaltInvocationError(
                'The default privileges option should not '
                'be set for object_type group')
357655
def has_object_permission(checker_name, user, obj):
    """"""
    if user and user.is_superuser:
        return True

    checker = PermissionsManager.retrieve_checker(checker_name)
    user_roles = get_user_roles(user)

    if not user_roles:
        user_roles = [None]

    return any([checker(user_role, user, obj) for user_role in user_roles])
149185
def ensure_compatible_admin(view):
    

    def wrapper(request, *args, **kwargs):
        user_roles = request.user.user_data.get('roles', [])
        if len(user_roles) != 1:
            context = {
                'message': 'I need to be able to manage user accounts. '
                           'My username is %s' % request.user.username
            }
            return render(request, 'mtp_common/user_admin/incompatible-admin.html', context=context)
        return view(request, *args, **kwargs)

    return wrapper
178536
def clean_entries(self, source_invoice: Invoice or None, settled_invoice: Invoice or None, account: Account, **kw):
        
        for form in self.forms:
            obj = form.instance
            assert isinstance(obj, AccountEntry)
            obj.account = account
            obj.source_invoice = source_invoice
            obj.settled_invoice = settled_invoice
            if obj.parent:
                if obj.amount is None:
                    obj.amount = obj.parent.amount
                if obj.type is None:
                    obj.type = obj.parent.type
                if obj.amount > obj.parent.amount > Decimal(0) or obj.amount < obj.parent.amount < Decimal(0):
                    raise ValidationError(_('Derived account entry amount cannot be larger than original'))
            for k, v in kw.items():
                setattr(obj, k, v)
335579
def for_account_hash(parent, account_hash):
        
        account = AccountProxy(parent)
        account.account_hash = account_hash
        if account.acquire():
            return account
        return None
985781
def ensure_object(self, object_type):
        
        rv = self.find_object(object_type)
        if rv is None:
            self.obj = rv = object_type()
        return rv
558562
def validate(self):
        
        if not self.principals:
            raise InvalidApplicationPolicyError(error_message='principals not provided')

        if not self.actions:
            raise InvalidApplicationPolicyError(error_message='actions not provided')

        if any(not self._PRINCIPAL_PATTERN.match(p) for p in self.principals):
            raise InvalidApplicationPolicyError(
                error_message='principal should be 12-digit AWS account ID or "*"')

        unsupported_actions = sorted(set(self.actions) - set(self.SUPPORTED_ACTIONS))
        if unsupported_actions:
            raise InvalidApplicationPolicyError(
                error_message='{} not supported'.format(', '.join(unsupported_actions)))

        return True
264951
function (account) {
	// check if DB is initialized
	if (typeof l_accounts === 'undefined') {
		LOG.error('DB module is not loaded, please enable DB module', l_name);
		return false;
	}

	if (l_accounts.hasOwnProperty(account) === false) {
		LOG.error('[' + account + '] not found', l_name);
		return false;
	}

	return true;
}
877296
def object_type=(object_type)
      validator = EnumAttributeValidator.new('String', ["ITEM", "DISCOUNT", "CATEGORY", "PLACEHOLDER"])
      unless validator.valid?(object_type)
        fail ArgumentError, "invalid value for 'object_type', must be one of #{validator.allowable_values}."
      end
      @object_type = object_type
    end