Device address validation result
The device address validation result object represents the result of a device address validation, typically used in device model configuration scripts.
The validateDeviceAddress function receives an object of this type as a parameter, which allows validating the given address and indicating the validation result.
Properties
### ok (boolean) The ok property indicates whether the validation was successful. The value true indicates that the specified address is correct, while the value false indicates that the address cannot be accepted. When returning the value true, it is also possible to optionally assign a value to the updatedAddress property, if the specified address needs to be modified. In that case, the platform will use the updatedAddress property value for the device.
Examples
This example validates a device address, verifying that it has 10 characters. If the validation is successful, the address is also converted to lowercase. If the validation is not successful, an error message is indicated.
function validateDeviceAddress(address, result)
{
result.ok = address.length == 10;
if (result.ok)
{
result.updatedAddress = address.toLowerCase();
}
else
{
result.errorMessage = {
en: "The address must be exactly 10 characters long",
es: "La dirección debe tener exactamente 10 caracteres"
};
}
}### updatedAddress (string) The updatedAddress property allows modifying the address being validated, so that if the validation is successful, a different address can be used. By default, the value of this property is equal to the address passed as a parameter to the validateDeviceAddress function. Typically, the address can be changed to give it a consistent format.
Examples
A complete example can be found in the documentation of the ok property above.
### errorMessage (string or multi-language literal) The errorMessage property allows indicating an error message when the ok property has the value false. To indicate an error message, a string or multi language literal value can be specified. If a multi language literal object is used, it is possible to indicate messages in different languages.
Examples
A complete example can be found in the documentation of the ok property above.