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)
| 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): |
nothing calls this directly
no outgoing calls
no test coverage detected