Skip to content

Commit 7eec8c5

Browse files
committed
chore: update joi scheme for rangekey
1 parent 0cb7b12 commit 7eec8c5

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

lib/apiGateway/schema.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,10 @@ const rangeKey = Joi.when('action', {
184184
.valid('post')
185185
.insensitive()
186186
.required(),
187-
then: Joi.string().error(
187+
then: Joi.forbidden().error(
188188
customErrorBuilder(
189-
'string.base',
190-
[
191-
'"rengeKey" must be a string when you define post to "method" and not define',
192-
' "action" expolicitly since the hashKey value is auto-generated on AWS end'
193-
].join('')
189+
'any.unknown',
190+
'you can not define "rangeKey" when post "method" is defined without "action"'
194191
)
195192
),
196193
otherwise: dynamodbDefaultKeyScheme

lib/apiGateway/validate.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,7 @@ describe('#validateServiceProxies()', () => {
14391439
)
14401440
})
14411441

1442-
it('should throw error if the "rangeKey" is not a string when the method is post and the action is not given', () => {
1442+
it('should throw error if the "rangeKey" is given when the method is post and the action is not given', () => {
14431443
serverlessApigatewayServiceProxy.serverless.service.custom = {
14441444
apiGatewayServiceProxies: [
14451445
{
@@ -1458,7 +1458,7 @@ describe('#validateServiceProxies()', () => {
14581458
}
14591459

14601460
expect(() => serverlessApigatewayServiceProxy.validateServiceProxies()).to.throw(
1461-
'child "rangeKey" fails because ["rengeKey" must be a string when you define post to "method" and not define "action" expolicitly since the hashKey value is auto-generated on AWS end]'
1461+
'child "dynamodb" fails because [child "rangeKey" fails because [you can not define "rangeKey" when post "method" is defined without "action"]]'
14621462
)
14631463
})
14641464

0 commit comments

Comments
 (0)