MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / isHttpStatusCode

Function isHttpStatusCode

packages/shared/src/utils/validate.ts:28–31  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

26
27const validCharsRE = /^[a-zA-Z0-9\-_+]*$/;
28export const isHttpStatusCode = (str: string): boolean => {
29 const output = parseInt(str, 10);
30 return !isNaN(output) && output >= 100 && output <= 599;
31};
32
33export const isValidUsername = (str: string): Validated => {
34 if (!validCharsRE.test(str)) return invalidCharError;

Callers 1

isValidUsernameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected