Skip to content

Commit 215e163

Browse files
committed
feat: validators client error with tests
1 parent 477ee91 commit 215e163

File tree

60 files changed

+945
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+945
-6
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isBadRequest
5+
* @description
6+
* Validate HTTP Status code 400 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 400
11+
*/
12+
function isBadRequest(statusCode) {
13+
return validateHttpStatus(statusCode, 400);
14+
}
15+
16+
export default isBadRequest;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isClientClosedRequest
5+
* @description
6+
* Validate HTTP Status code 499 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 499
11+
*/
12+
function isClientClosedRequest(statusCode) {
13+
return validateHttpStatus(statusCode, 499);
14+
}
15+
16+
export default isClientClosedRequest;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isConflict
5+
* @description
6+
* Validate HTTP Status code 409 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 409
11+
*/
12+
function isConflict(statusCode) {
13+
return validateHttpStatus(statusCode, 409);
14+
}
15+
16+
export default isConflict;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isConnectionClosedWithoutResponse
5+
* @description
6+
* Validate HTTP Status code 444 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 444
11+
*/
12+
function isConnectionClosedWithoutResponse(statusCode) {
13+
return validateHttpStatus(statusCode, 444);
14+
}
15+
16+
export default isConnectionClosedWithoutResponse;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isExpectationFailed
5+
* @description
6+
* Validate HTTP Status code 417 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 417
11+
*/
12+
function isExpectationFailed(statusCode) {
13+
return validateHttpStatus(statusCode, 417);
14+
}
15+
16+
export default isExpectationFailed;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isFailedDependency
5+
* @description
6+
* Validate HTTP Status code 424 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 424
11+
*/
12+
function isFailedDependency(statusCode) {
13+
return validateHttpStatus(statusCode, 424);
14+
}
15+
16+
export default isFailedDependency;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isForbidden
5+
* @description
6+
* Validate HTTP Status code 403 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 403
11+
*/
12+
function isForbidden(statusCode) {
13+
return validateHttpStatus(statusCode, 403);
14+
}
15+
16+
export default isForbidden;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isGone
5+
* @description
6+
* Validate HTTP Status code 410 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 410
11+
*/
12+
function isGone(statusCode) {
13+
return validateHttpStatus(statusCode, 410);
14+
}
15+
16+
export default isGone;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isImTeapot
5+
* @description
6+
* Validate HTTP Status code 418 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 418
11+
*/
12+
function isImTeapot(statusCode) {
13+
return validateHttpStatus(statusCode, 418);
14+
}
15+
16+
export default isImTeapot;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isLengthRequired
5+
* @description
6+
* Validate HTTP Status code 411 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 411
11+
*/
12+
function isLengthRequired(statusCode) {
13+
return validateHttpStatus(statusCode, 411);
14+
}
15+
16+
export default isLengthRequired;

0 commit comments

Comments
 (0)