Skip to main content

system.mes.location.validatePropertyValue

Description

Validates the specified parameters for a Location Property Values record and returns any validation errors. This only checks if the location property value object can be saved based on the attributes given.

Syntax

system.mes.location.validatePropertyValue(**property_data)

Parameters

ParameterTypeDescription
locationIdString (ULID)The ULID of the location.
propertyIdString (ULID)The ULID of the location property.
dataTypeStringThe data type of the property value. Must be the same as the data type of the property.
valueMixedThe value assigned to the property value if none is provided. The type is mixed as it depends on what dataType is.
idString (ULID)The ULID of the location property value (optional, for updating an existing property).
notesStringNotes related to the location property value.
enabledBooleanIndicates if the property value is active and enabled.
spare1StringAdditional field for user-defined context.
spare2StringAdditional field for user-defined context.
spare3StringAdditional 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

# Generate the object structure for a new property value object
property_value_data = system.mes.location.newPropertyValue()

# Define property value details
property_value_data['locationId'] = system.mes.location.getLocation('DairyCo')['id']
property_value_data['propertyId'] = system.mes.location.getProperty('Cows')['id']
property_value_data['dataType'] = 'Int' # Must be the same data type as the property
property_value_data['value'] = 100

# Validate location property value parameters
validation_errors = system.mes.location.validatePropertyValue(**property_value_data)

if len(validation_errors) > 0:
print('Validation errors found:', validation_errors)
else:
print('Location property value parameters are valid.')