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
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;
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;
+16
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;
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;
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;
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;
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;
+16
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;
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;
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;
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isLocked
5+
* @description
6+
* Validate HTTP Status code 423 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 423
11+
*/
12+
function isLocked(statusCode) {
13+
return validateHttpStatus(statusCode, 423);
14+
}
15+
16+
export default isLocked;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isMethodNotAllowed
5+
* @description
6+
* Validate HTTP Status code 405 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 405
11+
*/
12+
function isMethodNotAllowed(statusCode) {
13+
return validateHttpStatus(statusCode, 405);
14+
}
15+
16+
export default isMethodNotAllowed;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isMisdirectedRequest
5+
* @description
6+
* Validate HTTP Status code 421 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 421
11+
*/
12+
function isMisdirectedRequest(statusCode) {
13+
return validateHttpStatus(statusCode, 421);
14+
}
15+
16+
export default isMisdirectedRequest;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isNotAcceptable
5+
* @description
6+
* Validate HTTP Status code 406 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 406
11+
*/
12+
function isNotAcceptable(statusCode) {
13+
return validateHttpStatus(statusCode, 406);
14+
}
15+
16+
export default isNotAcceptable;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isNotFound
5+
* @description
6+
* Validate HTTP Status code 404 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 404
11+
*/
12+
function isNotFound(statusCode) {
13+
return validateHttpStatus(statusCode, 404);
14+
}
15+
16+
export default isNotFound;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isPayloadTooLarge
5+
* @description
6+
* Validate HTTP Status code 413 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 413
11+
*/
12+
function isPayloadTooLarge(statusCode) {
13+
return validateHttpStatus(statusCode, 413);
14+
}
15+
16+
export default isPayloadTooLarge;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isPaymentRequired
5+
* @description
6+
* Validate HTTP Status code 402 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 402
11+
*/
12+
function isPaymentRequired(statusCode) {
13+
return validateHttpStatus(statusCode, 402);
14+
}
15+
16+
export default isPaymentRequired;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isPreconditionFailed
5+
* @description
6+
* Validate HTTP Status code 412 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 412
11+
*/
12+
function isPreconditionFailed(statusCode) {
13+
return validateHttpStatus(statusCode, 412);
14+
}
15+
16+
export default isPreconditionFailed;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isPreconditionRequired
5+
* @description
6+
* Validate HTTP Status code 428 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 428
11+
*/
12+
function isPreconditionRequired(statusCode) {
13+
return validateHttpStatus(statusCode, 428);
14+
}
15+
16+
export default isPreconditionRequired;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isProxyAuthenticationRequired
5+
* @description
6+
* Validate HTTP Status code 407 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 407
11+
*/
12+
function isProxyAuthenticationRequired(statusCode) {
13+
return validateHttpStatus(statusCode, 407);
14+
}
15+
16+
export default isProxyAuthenticationRequired;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isRequestHeaderFieldsTooLarge
5+
* @description
6+
* Validate HTTP Status code 431 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 431
11+
*/
12+
function isRequestHeaderFieldsTooLarge(statusCode) {
13+
return validateHttpStatus(statusCode, 431);
14+
}
15+
16+
export default isRequestHeaderFieldsTooLarge;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isRequestTimeout
5+
* @description
6+
* Validate HTTP Status code 408 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 408
11+
*/
12+
function isRequestTimeout(statusCode) {
13+
return validateHttpStatus(statusCode, 408);
14+
}
15+
16+
export default isRequestTimeout;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import validateHttpStatus from '../validate-http-status';
2+
3+
/**
4+
* @module isRequestUriTooLong
5+
* @description
6+
* Validate HTTP Status code 414 type CLIENT ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 414
11+
*/
12+
function isRequestUriTooLong(statusCode) {
13+
return validateHttpStatus(statusCode, 414);
14+
}
15+
16+
export default isRequestUriTooLong;

0 commit comments

Comments
 (0)