in source/ui/src/util/Utils.ts [164:224]
export function validateConnectionDefinition(params: ConnectionDefinition): KeyStringValue {
const errors: KeyStringValue = {};
const { connectionName, area, machineName, process, siteName } = params;
/**
* Checks the connection name to meet the Lambda function name constraints.
* The connection name only allows alphanumeric characters, hypens, and underscores.
* The maximum characters are 30 characters since the solution preserve characters.
*/
validateAlphaNumericHyphenUnderscoreStrinng({
value: connectionName,
maxLength: MAX_CHARACTERS,
errors,
errorKeyName: 'connectionName',
errorMessage: I18n.get('invalid.connection.name')
});
validateAlphaNumericHyphenUnderscoreStrinng({
value: siteName as string,
maxLength: MAX_CHARACTERS,
errors,
errorKeyName: 'siteName',
errorMessage: I18n.get('invalid.alphanumeric.hyphens.underscores').replace('{name}', 'Site name')
});
validateAlphaNumericHyphenUnderscoreStrinng({
value: area as string,
maxLength: MAX_CHARACTERS,
errors,
errorKeyName: 'area',
errorMessage: I18n.get('invalid.alphanumeric.hyphens.underscores').replace('{name}', 'Area')
});
validateAlphaNumericHyphenUnderscoreStrinng({
value: process as string,
maxLength: MAX_CHARACTERS,
errors,
errorKeyName: 'process',
errorMessage: I18n.get('invalid.alphanumeric.hyphens.underscores').replace('{name}', 'Process')
});
validateAlphaNumericHyphenUnderscoreStrinng({
value: machineName as string,
maxLength: MAX_CHARACTERS,
errors,
errorKeyName: 'machineName',
errorMessage: I18n.get('invalid.alphanumeric.hyphens.underscores').replace('{name}', 'Machine name')
});
/**
* Checks send data to IoT Sitewise, IoT topic and stream manager.
* One of those should be set to be sent.
*/
if (!params.sendDataToIoTSitewise && !params.sendDataToIoTTopic && !params.sendDataToKinesisDataStreams) {
errors.sendDataTo = I18n.get('invalid.send.data.to');
}
if (params.protocol === MachineProtocol.OPCDA) {
validateOpcDa(params.opcDa!, errors);
} else if (params.protocol === MachineProtocol.OPCUA) {
validateOpcUa(params.opcUa!, errors);
}
return errors;
}