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

Method validate

st2common/st2common/models/api/pack.py:170–197  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

168 super(PackAPI, self).__init__(**values)
169
170 def validate(self):
171 # We wrap default validate() implementation and throw a more user-friendly exception in
172 # case pack version doesn't follow a valid semver format and other errors
173 try:
174 super(PackAPI, self).validate()
175 except jsonschema.ValidationError as e:
176 msg = six.text_type(e)
177
178 # Invalid version
179 if "Failed validating 'pattern' in schema['properties']['version']" in msg:
180 new_msg = (
181 'Pack version "%s" doesn\'t follow a valid semver format. Valid '
182 "versions and formats include: 0.1.0, 0.2.1, 1.1.0, etc."
183 % (self.version)
184 )
185 new_msg += "\n\n" + msg
186 raise jsonschema.ValidationError(new_msg)
187
188 # Invalid ref / name
189 if "Failed validating 'pattern' in schema['properties']['ref']" in msg:
190 new_msg = (
191 "Pack ref / name can only contain valid word characters (a-z, 0-9 and "
192 "_), dashes are not allowed."
193 )
194 new_msg += "\n\n" + msg
195 raise jsonschema.ValidationError(new_msg)
196
197 raise e
198
199 @classmethod
200 def to_model(cls, pack):

Callers 15

_register_pack_dbMethod · 0.95
validate_responseFunction · 0.45
create_requestFunction · 0.45
create_trigger_type_dbFunction · 0.45
validateMethod · 0.45
_register_actionMethod · 0.45
register_runnerFunction · 0.45
register_rule_typesFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected