Skip to main content

system.mes.shift.validateShift

Description

Validates the specified parameters for a Shifts record and returns any validation errors. This only checks if the object can be saved based on the attributes given.

Syntax

system.mes.shift.validateShift(**shift_data)

Parameters

ParameterTypeNullableDescription
locationIdString (ULID)FalseThe ULID of the location where the shift runs.
locationPathStringTrueThe path of the location where the shift runs. For display purposes.
nameStringFalseThe name of the shift.
descriptionStringTrueA detailed description of the shift.
shiftScheduleNameStringTrueThe name of the schedule that defines this shift's timings (when using schedule-based timing).
shiftScheduleSourceString (Enum)FalseThe source of timing (e.g., IGNITION_SCHEDULE, IGNITION_EXPRESSION).
currentRecordIdString (ULID)TrueThe current shift record id for the shift (if any).
runningConflictStrategyString (Enum)FalseStrategy when a new shift starts while another is running (e.g., STOP_PREVIOUS, THROW_EXCEPTION).
startTriggerExpressionStringTrueThe expression used to determine when the shift should start.
startTriggerTypeString (Enum)FalseThe trigger mechanism used to start the shift (e.g., RISING_EDGE, FALLING_EDGE, CHANGE).
stopTriggerExpressionStringTrueThe expression used to determine when the shift should end.
stopTriggerTypeString (Enum)FalseThe trigger mechanism used to end the shift (e.g., RISING_EDGE, FALLING_EDGE, CHANGE).
idString (ULID)TrueThe ULID of the shift.
notesStringTrueNotes related to the shift.
enabledBooleanTrueIndicates if the shift is active and enabled. Default value is true.
spare1StringTrueAdditional field for user-defined context.
spare2StringTrueAdditional field for user-defined context.
spare3StringTrueAdditional field for user-defined context.

Returns

Returns a JSON object where keys are field names and values are lists of validation violation messages.

Code Examples

shift = system.mes.shift.newShift()
shift['name'] = '' # invalid (required)
violations = system.mes.shift.validateShift(**shift)
print(violations)