Skip to content

Commit 477ee91

Browse files
committed
feat: validators type server error
1 parent 79a4804 commit 477ee91

25 files changed

+386
-0
lines changed

src/validators/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,29 @@ export {
4343
export { default as isUnauthorized } from './client-error/is-unauthorized';
4444

4545
// 5×× Server Error
46+
export { default as isBadGateway } from './server-error/is-bad-gateway';
47+
export { default as isGatewayTimeout } from './server-error/is-gateway-timeout';
48+
export {
49+
default as isHttpVersionNotSupported
50+
} from './server-error/is-http-version-not-supported';
51+
export {
52+
default as isInsufficientStorage
53+
} from './server-error/is-insufficient-storage';
54+
export {
55+
default as isInternalServerError
56+
} from './server-error/is-internal-server-error';
57+
export { default as isLoopDetected } from './server-error/is-loop-detected';
58+
export {
59+
default as isNetworkAuthenticationRequired
60+
} from './server-error/is-network-authentication-required';
61+
export {
62+
default as isNetworkConnectTimeoutError
63+
} from './server-error/is-network-connect-timeout-error';
64+
export { default as isNotExtended } from './server-error/is-not-extended';
65+
export { default as isNotImplemented } from './server-error/is-not-implemented';
66+
export {
67+
default as isServiceUnavailable
68+
} from './server-error/is-service-unavailable';
69+
export {
70+
default as isVariantAlsoNegotiates
71+
} from './server-error/is-variant-also-negotiates';
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 isBadGateway
5+
* @description
6+
* Validate HTTP Status code 502 type SERVER ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 502
11+
*/
12+
function isBadGateway(statusCode) {
13+
return validateHttpStatus(statusCode, 502);
14+
}
15+
16+
export default isBadGateway;
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 isGatewayTimeout
5+
* @description
6+
* Validate HTTP Status code 504 type SERVER ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 504
11+
*/
12+
function isGatewayTimeout(statusCode) {
13+
return validateHttpStatus(statusCode, 504);
14+
}
15+
16+
export default isGatewayTimeout;
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 isHttpVersionNotSupported
5+
* @description
6+
* Validate HTTP Status code 505 type SERVER ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 504
11+
*/
12+
function isHttpVersionNotSupported(statusCode) {
13+
return validateHttpStatus(statusCode, 505);
14+
}
15+
16+
export default isHttpVersionNotSupported;
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 isInsufficientStorage
5+
* @description
6+
* Validate HTTP Status code 507 type SERVER ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 507
11+
*/
12+
function isInsufficientStorage(statusCode) {
13+
return validateHttpStatus(statusCode, 507);
14+
}
15+
16+
export default isInsufficientStorage;
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 isInternalServerError
5+
* @description
6+
* Validate HTTP Status code 500 type SERVER ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 500
11+
*/
12+
function isInternalServerError(statusCode) {
13+
return validateHttpStatus(statusCode, 500);
14+
}
15+
16+
export default isInternalServerError;
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 isLoopDetected
5+
* @description
6+
* Validate HTTP Status code 508 type SERVER ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 508
11+
*/
12+
function isLoopDetected(statusCode) {
13+
return validateHttpStatus(statusCode, 508);
14+
}
15+
16+
export default isLoopDetected;
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 isNetworkAuthenticationRequired
5+
* @description
6+
* Validate HTTP Status code 511 type SERVER ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 511
11+
*/
12+
function isNetworkAuthenticationRequired(statusCode) {
13+
return validateHttpStatus(statusCode, 511);
14+
}
15+
16+
export default isNetworkAuthenticationRequired;
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 isNetworkConnectTimeoutError
5+
* @description
6+
* Validate HTTP Status code 599 type SERVER ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 599
11+
*/
12+
function isNetworkConnectTimeoutError(statusCode) {
13+
return validateHttpStatus(statusCode, 599);
14+
}
15+
16+
export default isNetworkConnectTimeoutError;
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 isNotExtended
5+
* @description
6+
* Validate HTTP Status code 510 type SERVER ERROR
7+
*
8+
* @param {Integer} statusCode - The HTTP Status code
9+
* @return {Boolean}
10+
* @throws {HTTPStatusError} When the statusCode is different then 510
11+
*/
12+
function isNotExtended(statusCode) {
13+
return validateHttpStatus(statusCode, 510);
14+
}
15+
16+
export default isNotExtended;

0 commit comments

Comments
 (0)