Source code for py_abac.policy.conditions.string.ends_with

"""
    String ends with conditions
"""

from marshmallow import post_load

from .base import StringCondition, StringConditionSchema


[docs]class EndsWith(StringCondition): """ Condition for string `what` ends with `value` """ def _is_satisfied(self, what) -> bool: if self.case_insensitive: return what.lower().endswith(self.value.lower()) return what.endswith(self.value)
[docs]class EndsWithSchema(StringConditionSchema): """ JSON schema for ends with string condition """
[docs] @post_load def post_load(self, data, **_): # pylint: disable=missing-docstring,no-self-use return EndsWith(**data)