package org.wso2.carbon.device.mgt.ios.services.impl.util;

import org.wso2.carbon.device.mgt.ios.beans.ErrorResponse;

public class RequestValidationUtil {

    public static void validatePaginationParameters(int offset, int limit) {
        if (offset < 0) {
            throw new InputValidationException(
                    new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request parameter offset is a " +
                                                                                              "negative value.")
                            .build());
        }
        if (limit < 0) {
            throw new InputValidationException(
                    new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request parameter limit is a " +
                                                                                              "negative value.")
                            .build());
        }
        if (limit > 100) {
            throw new InputValidationException(
                    new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request parameter limit should" +
                                                                                              " be less than or equal" +
                                                                                              " to 100.")
                            .build());
        }

    }
}
