forked from osopromadze/Spring-Boot-Blog-REST-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppUtils.java
More file actions
21 lines (16 loc) · 708 Bytes
/
AppUtils.java
File metadata and controls
21 lines (16 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package com.sopromadze.blogapi.utils;
import org.springframework.http.HttpStatus;
import com.sopromadze.blogapi.exception.BlogapiException;
public class AppUtils {
public static void validatePageNumberAndSize(int page, int size) {
if(page < 0) {
throw new BlogapiException(HttpStatus.BAD_REQUEST, "Page number cannot be less than zero.");
}
if(size < 0) {
throw new BlogapiException(HttpStatus.BAD_REQUEST, "Size number cannot be less than zero.");
}
if(size > AppConstants.MAX_PAGE_SIZE) {
throw new BlogapiException(HttpStatus.BAD_REQUEST, "Page size must not be greater than " + AppConstants.MAX_PAGE_SIZE);
}
}
}