nosdigitalmedia's picture
Attempt to set up application
4e0f321
raw
history blame
697 Bytes
from src.rule_based_system.Rule import Rule
from src.rule_based_system.Verdict import Verdict
TEXT_SIZE_LIMIT = 500
class TextLengthRule(Rule):
def get_verdict(self, comment_text: str) -> Verdict:
allows = True \
and not self.is_empty(comment_text) \
and not self.is_too_long(comment_text, TEXT_SIZE_LIMIT)
return Verdict(allows, [])
@staticmethod
def is_empty(text):
return len(text) == 0
@staticmethod
def is_too_long(text, limit):
return len(text) > limit
def is_strict(self) -> bool:
return True
@staticmethod
def get_rule_description() -> str:
return 'Inappropriate text length'