Skip to content

Commit

Permalink
Enabled FunctionContextDetailsValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
LexiconCode committed Apr 4, 2020
1 parent 18e4849 commit 936c244
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

from castervoice.lib.const import CCRType
from castervoice.lib.ctrl.mgr.validation.details.base_validator import BaseDetailsValidator

Expand All @@ -9,10 +10,11 @@ class FunctionContextDetailsValidator(BaseDetailsValidator):
'''
def validate(self, details):
invalidations = []
if details.function_context is not bool:
invalidations.append("Function Context must return a bool value")
if details.declared_ccrtype == CCRType.GLOBAL or details.declared_ccrtype == CCRType.SELFMOD:
invalidations.append("Function Context cannot be used with `CCRType.GLOBAL` or `CCRType.SELFMOD`")
if details.function_context is not None:
if type(details.function_context) != bool:
invalidations.append("Function Context must return a bool value")
if details.declared_ccrtype == CCRType.GLOBAL or details.declared_ccrtype == CCRType.SELFMOD:
invalidations.append("Function Context cannot be used with `CCRType.GLOBAL` or `CCRType.SELFMOD`")


return None if len(invalidations) == 0 else ", ".join(invalidations)
4 changes: 3 additions & 1 deletion castervoice/lib/ctrl/nexus.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from castervoice.lib.ctrl.mgr.validation.details.ccr_validator import CCRDetailsValidator
from castervoice.lib.ctrl.mgr.validation.details.details_validation_delegator import DetailsValidationDelegator
from castervoice.lib.ctrl.mgr.validation.details.non_ccr_validator import NonCCRDetailsValidator
from castervoice.lib.ctrl.mgr.validation.details.function_context_validator import FunctionContextDetailsValidator
from castervoice.lib.ctrl.mgr.validation.rules.mergerule_validator import IsMergeRuleValidator
from castervoice.lib.ctrl.mgr.validation.rules.not_treerule_validator import NotTreeRuleValidator
from castervoice.lib.ctrl.mgr.validation.rules.selfmod_validator import CCRSelfModifyingRuleValidator
Expand Down Expand Up @@ -108,7 +109,8 @@ def _create_details_validator():
return DetailsValidationDelegator(
CCRDetailsValidator(),
AppCCRDetailsValidator(),
NonCCRDetailsValidator()
NonCCRDetailsValidator(),
FunctionContextDetailsValidator()
)

@staticmethod
Expand Down

0 comments on commit 936c244

Please sign in to comment.