Source code for py_abac.policy.conditions.others.exists

"""
    Attribute exists conditions
"""
from marshmallow import Schema, post_load

from ..base import ConditionBase


[docs]class Exists(ConditionBase): """ Condition for attribute value exists """
[docs] def is_satisfied(self, ctx) -> bool: return ctx.attribute_value is not None
[docs]class ExistsSchema(Schema): """ JSON schema for attribute value exists conditions """
[docs] @post_load def post_load(self, data, **_): # pylint: disable=missing-docstring,no-self-use,unused-argument return Exists()