Skip to content

Commit

Permalink
chore: Add CursorLimit constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
laminne committed Dec 16, 2024
1 parent 6198728 commit a33ac55
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/notification/adaptor/repository/dummy/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
} from '../../../model/notification.js';
import {
NOTIFICATION_DEFAULT_LIMIT,
NOTIFICATION_MAX_LIMIT,
type NotificationFilter,
type NotificationRepository,
} from '../../../model/repository/notification.js';
Expand Down Expand Up @@ -48,6 +49,10 @@ export class InMemoryNotificationRepository implements NotificationRepository {
const limit = Option.isSome(filter.limit)
? Option.unwrap(filter.limit)
: NOTIFICATION_DEFAULT_LIMIT;
if (limit > NOTIFICATION_MAX_LIMIT) {
// ToDo: Define NotificationCursorLimitOutOfRangeError
return Result.err(new Error('Limit exceeds the maximum value'));
}

if (Option.isNone(filter.cursor)) {
return Result.ok(res.slice(0, limit));
Expand Down

0 comments on commit a33ac55

Please sign in to comment.