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

Method validate

st2common/st2common/models/api/base.py:63–85  ·  view source on GitHub ↗

Perform validation and return cleaned object on success. Note: This method doesn't mutate this object in place, but it returns a new one. :return: Cleaned / validated object.

(self)

Source from the content-addressed store, hash-verified

61 return vars(self)
62
63 def validate(self):
64 """
65 Perform validation and return cleaned object on success.
66
67 Note: This method doesn't mutate this object in place, but it returns a new one.
68
69 :return: Cleaned / validated object.
70 """
71 from st2common.util import schema as util_schema
72
73 schema = getattr(self, "schema", {})
74 attributes = vars(self)
75
76 cleaned = util_schema.validate(
77 instance=attributes,
78 schema=schema,
79 cls=util_schema.CustomValidator,
80 use_default=True,
81 allow_default_none=True,
82 )
83
84 # Note: We use type() instead of self.__class__ since self.__class__ confuses pylint
85 return type(self)(**cleaned)
86
87 @classmethod
88 def _from_model(cls, model, mask_secrets=False):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected