Skip to content

Commit

Permalink
Add InvalidArgumentException and correct validations to get tests pas…
Browse files Browse the repository at this point in the history
…sing locally
  • Loading branch information
mhart committed Apr 4, 2018
1 parent 6aafef2 commit 1803a49
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
8 changes: 8 additions & 0 deletions actions/listShards.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
var once = require('once'),
db = require('../db')

module.exports = function listShards(store, data, cb) {

if (!data.StreamName && !data.NextToken) {
return cb(db.clientError('InvalidArgumentException', 'Either NextToken or StreamName should be provided.'))
} else if (data.StreamName && data.NextToken) {
return cb(db.clientError('InvalidArgumentException', 'NextToken and StreamName cannot be provided together.'))
}

//TODO get stream according to the given input [NextToken|StreamCreationTimestamp|StreamName]
store.getStream(data.StreamName, function(err, stream) {
if (err) return cb(err)
Expand Down
22 changes: 8 additions & 14 deletions validations/listShards.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,17 @@ exports.types = {
greaterThanOrEqual: 1,
lessThanOrEqual: 10000,
},
//TODO validate exactly one of [NextToken|StreamCreationTimestamp|StreamName]
// NextToken: {
// type: 'String',
// regex: '[a-zA-Z0-9_.-]+',
// lengthGreaterThanOrEqual: 1,
// lengthLessThanOrEqual: 1048576,
// },
//TODO add Timestamp type
// StreamCreationTimestamp: {
// type: 'Timestamp',
// notNull: true,
// },
NextToken: {
type: 'String',
lengthGreaterThanOrEqual: 1,
},
StreamCreationTimestamp: {
type: 'Timestamp',
},
StreamName: {
type: 'String',
notNull: true,
regex: '[a-zA-Z0-9_.-]+',
lengthGreaterThanOrEqual: 1,
lengthLessThanOrEqual: 128,
}
},
}

0 comments on commit 1803a49

Please sign in to comment.