in source/lambda/lib/validations.ts [264:294]
function validateOpcUaConnectionDefinition(opcUa: ConnectionBuilderTypes.OpcUaDefinition) {
// Since the type of array is also `object`, it checks if the value is an array.
if (typeof opcUa !== 'object' || Array.isArray(opcUa) || Object.keys(opcUa).length === 0) {
throw new LambdaError({
message: '"opcUa" is missing or invalid from the connection definition. See the implementation guide.',
name: 'ValidationError',
statusCode: 400
});
}
const { machineIp, serverName, port } = opcUa;
validateIpAddress(machineIp);
if (typeof serverName !== 'string' || serverName.trim() === '' || serverName.trim().length > ValidationsTypes.MAX_OPCUA_SERVER_NAME_CHARACTERS) {
throw new LambdaError({
message: `"serverName" is missing or invalid from the connection definition. It should be a non-empty string up to ${ValidationsTypes.MAX_OPCUA_SERVER_NAME_CHARACTERS} characters.`,
name: 'ValidationError',
statusCode: 400
});
}
if (!EMPTY_TYPES.includes(port)) {
if (!Number.isInteger(port) || port < ValidationsTypes.MIN_PORT || port > ValidationsTypes.MAX_PORT) {
throw new LambdaError({
message: `"port" is invalid from the connection definition. It should be an integer number between ${ValidationsTypes.MIN_PORT} and ${ValidationsTypes.MAX_PORT}.`,
name: 'ValidationError',
statusCode: 400
});
}
}
}