T-954157790482088: add isProfileNumberValid utility function

This commit is contained in:
Okechi Onyeje 2019-01-01 16:20:35 -05:00
parent 5a5bda6bb3
commit 50b6f9b0fa
2 changed files with 12 additions and 1 deletions

View File

@ -21,4 +21,5 @@ module.exports = {
MISSING_BODY_ATTRIBUTES: 'request/missing-body-attributes',
//Profile Errors
MAX_NUMBER_OF_PROFILES_REACHED: 'profile/max-number-of-profiles-are-being-used',
NO_PROFILE_FOUND_FOR_NUMBER: 'profile/no-profile-found-for-number'
};

View File

@ -43,8 +43,18 @@ function isBodyValid(isValid, response) {
return true;
}
function isProfileNumberValid(profileNumber, response) {
if (profileNumber > 4 || profileNumber < 1) {
response.status(http.BAD_REQUEST).json({error: errors.NO_PROFILE_FOUND_FOR_NUMBER});
return false;
} else {
return true;
}
}
module.exports = {
isAppSecretValid,
isBodyValid,
getSessionIdFromAuthHeader
getSessionIdFromAuthHeader,
isProfileNumberValid
};