diff --git a/src/main/java/gyro/aws/dynamodb/DynamoDbGlobalSecondaryIndex.java b/src/main/java/gyro/aws/dynamodb/DynamoDbGlobalSecondaryIndex.java index dadf0670d..2a8362683 100644 --- a/src/main/java/gyro/aws/dynamodb/DynamoDbGlobalSecondaryIndex.java +++ b/src/main/java/gyro/aws/dynamodb/DynamoDbGlobalSecondaryIndex.java @@ -24,6 +24,7 @@ import gyro.aws.Copyable; import gyro.core.resource.Diffable; import gyro.core.resource.Updatable; +import gyro.core.validation.Min; import gyro.core.validation.Required; import gyro.core.validation.ValidStrings; import gyro.core.validation.ValidationError; @@ -84,6 +85,7 @@ public void setRangeKey(String rangeKey) { * The maximum number of writes per second for this table before an exception is thrown. Required if ``billing-mode`` is set to ``PROVISIONED``. */ @Updatable + @Min(1) public Long getWriteCapacity() { return writeCapacity; } @@ -96,6 +98,7 @@ public void setWriteCapacity(Long writeCapacity) { * The maximum number of reads per second for this table before an exception is thrown. Required if ``billing-mode`` is set to ``PROVISIONED``. */ @Updatable + @Min(1) public Long getReadCapacity() { return readCapacity; } @@ -234,8 +237,7 @@ public List validate(Set configuredFields) { "'read-capacity' and 'write-capacity' must both be provided when the table 'billing-mode' is set to 'PROVISIONED'!")); } - if ("PAY_PER_REQUEST".equals(parentTable.getBillingMode()) && (getReadCapacity() != null - || getWriteCapacity() != null)) { + if ("PAY_PER_REQUEST".equals(parentTable.getBillingMode()) && ((getReadCapacity() != null && getReadCapacity() > 0) || (getWriteCapacity() != null && getWriteCapacity() > 0))) { errors.add(new ValidationError( this, null, diff --git a/src/main/java/gyro/aws/dynamodb/DynamoDbTableResource.java b/src/main/java/gyro/aws/dynamodb/DynamoDbTableResource.java index 68633b7be..d1d8d8e4a 100644 --- a/src/main/java/gyro/aws/dynamodb/DynamoDbTableResource.java +++ b/src/main/java/gyro/aws/dynamodb/DynamoDbTableResource.java @@ -42,6 +42,7 @@ import gyro.core.resource.Resource; import gyro.core.resource.Updatable; import gyro.core.scope.State; +import gyro.core.validation.Min; import gyro.core.validation.Regex; import gyro.core.validation.Required; import gyro.core.validation.ValidStrings; @@ -253,6 +254,7 @@ public void setLocalSecondaryIndex(Set localSeconda * The maximum number of writes per second for this table before an exception is thrown. Required if ``billing-mode`` is set to ``PROVISIONED``. */ @Updatable + @Min(1) public Long getWriteCapacity() { return writeCapacity; } @@ -265,6 +267,7 @@ public void setWriteCapacity(Long writeCapacity) { * The maximum number of reads per second for this table before an exception is thrown. Required if ``billing-mode`` is set to ``PROVISIONED``. */ @Updatable + @Min(1) public Long getReadCapacity() { return readCapacity; } @@ -598,7 +601,7 @@ public List validate(Set configuredFields) { "'read-capacity' and 'write-capacity' must both be provided when 'billing-mode' is set to 'PROVISIONED'!")); } - if ("PAY_PER_REQUEST".equals(getBillingMode()) && (getReadCapacity() != null || getWriteCapacity() != null)) { + if ("PAY_PER_REQUEST".equals(getBillingMode()) && ((getReadCapacity() != null && getReadCapacity() > 0) || (getWriteCapacity() != null && getWriteCapacity() > 0))) { errors.add(new ValidationError( this, null,