"""
Logical AND conditions
"""
from marshmallow import post_load
from .base import LogicCondition, LogicConditionSchema
[docs]class AllOf(LogicCondition):
"""
Condition for all of the sub-rules are satisfied
"""
[docs] def is_satisfied(self, ctx) -> bool:
return all(value.is_satisfied(ctx) for value in self.values)
[docs]class AllOfSchema(LogicConditionSchema):
"""
JSON schema for all of logical condition
"""
[docs] @post_load
def post_load(self, data, **_): # pylint: disable=missing-docstring,no-self-use
return AllOf(**data)