55 from meshroom .core .node import Node
66
77
8- SuccessResponse = (True , [])
8+ def success () -> tuple [bool , list [str ]]:
9+ return (True , [])
910
11+ def error (* messages : str ) -> tuple [bool , list [str ]]:
12+ return (False , messages )
1013
1114class AttributeValidator (object ):
1215 """ Interface for an attribute validation
@@ -41,9 +44,9 @@ class NotEmptyValidator(AttributeValidator):
4144 def __call__ (self , node : "Node" , attribute : "Attribute" ) -> tuple [bool , list [str ]]:
4245
4346 if attribute .value is None or attribute .value == "" :
44- return ( False , [ "Empty value are not allowed" ] )
47+ return error ( "Empty value are not allowed" )
4548
46- return SuccessResponse
49+ return success ()
4750
4851
4952class RangeValidator (AttributeValidator ):
@@ -57,7 +60,7 @@ def __init__(self, min, max):
5760 def __call__ (self , node :"Node" , attribute : "Attribute" ) -> tuple [bool , list [str ]]:
5861
5962 if attribute .value < self ._min or attribute .value > self ._max :
60- return ( False , [ f"Value should be greater than { self ._min } and less than { self ._max } " ,
61- f"({ self ._min } < { attribute .value } < { self ._max } )" ] )
63+ return error ( f"Value should be greater than { self ._min } and less than { self ._max } " ,
64+ f"({ self ._min } < { attribute .value } < { self ._max } )" )
6265
63- return SuccessResponse
66+ return success ()
0 commit comments