tamaki.mes.validations.setValidationMessages
Description
Displays validation failures on the project's custom Input components.
The function iterates the children of parentElement. For each child whose name contains Input and
which is an embedded view of TamakiMES/_components/Input (or TamakiMES/_components/MESDropdowns),
it matches the input's validationName param: falling back to its name param: against the keys
of validations. On a match, the messages for that key are joined with commas and written to the
input's validationText param.
If a child whose name contains Input is not actually one of these embedded views, an exception is
raised.
Syntax
tamaki.mes.validations.setValidationMessages(parentElement, validations)
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
parentElement | Object | False | The Perspective component containing the Input children. Children must be embedded views of TamakiMES/_components/Input. |
validations | Object | False | The result of an MES validate function: a mapping of field name to a list of failure messages (for example from system.mes.material.validateMaterial(...)). |
Returns
This method does not return a value. It sets the validationText param on matching inputs as a side
effect.
Code Examples
# In a save handler: validate, then show any failures on the inputs and stop
req = dict(self.view.custom.req)
validations = dict(system.mes.dashboard.validateWidgetParameter(req))
if validations:
tamaki.mes.validations.setValidationMessages(self.view.getChild("root"), validations)
self.view.custom.success = None
return