MCPcopy Create free account
hub / github.com/PalisadoesFoundation/talawa-api / validatePositiveInteger

Function validatePositiveInteger

scripts/setup/validators.ts:172–183  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

170 * @returns `true` if valid, or an error message string if invalid.
171 */
172export function validatePositiveInteger(input: string): true | string {
173 const trimmed = input.trim();
174 // Strictly verify it matches an unsigned integer pattern
175 if (!/^\d+$/.test(trimmed)) {
176 return "Please enter a valid positive integer.";
177 }
178 const value = Number.parseInt(trimmed, 10);
179 if (value < 1) {
180 return "Please enter a valid positive integer.";
181 }
182 return true;
183}
184
185/**
186 * Validates that the input is a valid cron expression.

Callers 1

setup.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected