MCPcopy Create free account
hub / github.com/StackStorm/st2 / validate

Method validate

st2client/st2client/utils/interactive.py:228–239  ·  view source on GitHub ↗
(input, spec)

Source from the content-addressed store, hash-verified

226
227 @staticmethod
228 def validate(input, spec):
229 if not input and (not spec.get("required", None) or spec.get("default", None)):
230 return
231
232 if not input.isdigit():
233 raise validation.ValidationError(len(input), "Not a number")
234
235 enum = spec.get("enum")
236 try:
237 enum[int(input)]
238 except IndexError:
239 raise validation.ValidationError(len(input), "Out of bounds")
240
241 def _construct_template(self):
242 self.template = "{0}: "

Callers 6

validateMethod · 0.45
validateMethod · 0.45
validateMethod · 0.45
validateMethod · 0.45
validateMethod · 0.45
assertPromptValidateMethod · 0.45

Calls 1

getMethod · 0.45

Tested by 1

assertPromptValidateMethod · 0.36