in Libraries/src/Amazon.Lambda.Annotations/SQS/SQSEventAttribute.cs [123:173]
internal List<string> Validate()
{
var validationErrors = new List<string>();
if (IsBatchSizeSet && (BatchSize < 1 || BatchSize > 10000))
{
validationErrors.Add($"{nameof(SQSEventAttribute.BatchSize)} = {BatchSize}. It must be between 1 and 10000");
}
if (IsMaximumConcurrencySet && (MaximumConcurrency < 2 || MaximumConcurrency > 1000))
{
validationErrors.Add($"{nameof(SQSEventAttribute.MaximumConcurrency)} = {MaximumConcurrency}. It must be between 2 and 1000");
}
if (IsMaximumBatchingWindowInSecondsSet && (MaximumBatchingWindowInSeconds < 0 || MaximumBatchingWindowInSeconds > 300))
{
validationErrors.Add($"{nameof(SQSEventAttribute.MaximumBatchingWindowInSeconds)} = {MaximumBatchingWindowInSeconds}. It must be between 0 and 300");
}
if (IsBatchSizeSet && BatchSize > 10 && (!IsMaximumBatchingWindowInSecondsSet || MaximumBatchingWindowInSeconds < 1))
{
validationErrors.Add($"{nameof(SQSEventAttribute.MaximumBatchingWindowInSeconds)} is not set or set to a value less than 1. " +
$"It must be set to at least 1 when {nameof(SQSEventAttribute.BatchSize)} is greater than 10");
}
// The queue is FIFO if the queue ARN ends in ".fifo"
var isFifo = !Queue.StartsWith("@") && Queue.EndsWith(".fifo");
if (isFifo)
{
if (IsMaximumBatchingWindowInSecondsSet)
{
validationErrors.Add($"{nameof(SQSEventAttribute.MaximumBatchingWindowInSeconds)} must not be set when the event source mapping is for a FIFO queue");
}
if (IsBatchSizeSet && BatchSize > 10)
{
validationErrors.Add($"{nameof(SQSEventAttribute.BatchSize)} = {BatchSize}. It must be less than or equal to 10 when the event source mapping is for a FIFO queue");
}
}
if (!Queue.StartsWith("@"))
{
var arnTokens = Queue.Split(new char[] { ':' }, 6);
if (arnTokens.Length != 6)
{
validationErrors.Add($"{nameof(SQSEventAttribute.Queue)} = {Queue}. The SQS queue ARN is invalid. The ARN format is 'arn:<partition>:sqs:<region>:<account-id>:<queue-name>'");
}
}
if (IsResourceNameSet && !_resourceNameRegex.IsMatch(ResourceName))
{
validationErrors.Add($"{nameof(SQSEventAttribute.ResourceName)} = {ResourceName}. It must only contain alphanumeric characters and must not be an empty string");
}
return validationErrors;
}