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
@@ -18,9 +21,9 @@ class NotEmptyValidator(AttributeValidator):
1821 def __call__ (self , node : "Node" , attribute : "Attribute" ) -> tuple [bool , list [str ]]:
1922
2023 if attribute .value is None or attribute .value == "" :
21- return ( False , [ "Empty value are not allowed" ] )
24+ return error ( "Empty value are not allowed" )
2225
23- return SuccessResponse
26+ return success ()
2427
2528
2629class RangeValidator (AttributeValidator ):
@@ -32,7 +35,7 @@ def __init__(self, min, max):
3235 def __call__ (self , node :"Node" , attribute : "Attribute" ) -> tuple [bool , list [str ]]:
3336
3437 if attribute .value < self ._min or attribute .value > self ._max :
35- return ( False , [ f"Value should be greater than { self ._min } and less than { self ._max } " ,
36- f"({ self ._min } < { attribute .value } < { self ._max } )" ] )
38+ return error ( f"Value should be greater than { self ._min } and less than { self ._max } " ,
39+ f"({ self ._min } < { attribute .value } < { self ._max } )" )
3740
38- return SuccessResponse
41+ return success ()
0 commit comments