Skip to content

Conversation

@Ujjwal-here
Copy link

@Ujjwal-here Ujjwal-here commented Aug 24, 2025

Description

This PR adds a new isDigit validation function to check if a string contains only numeric digits (0-9), along with its corresponding API endpoint.

Changes Made

New Function

  • ValidationFunctions.isDigit(str) - Returns true if the input string contains only digits (0-9), false otherwise
  • Added comprehensive JSDoc documentation with examples

New API Endpoint

  • POST /api/isDigit - REST endpoint that accepts inputString and returns boolean result
  • Follows established API patterns with proper error handling
  • Includes comprehensive Swagger documentation
  • Returns 400 error for missing input parameters

Tests

  • Unit Tests (test/unit/isDigit.test.js) - Tests the validation function directly
  • Integration Tests (test/integration/isDigit.test.js) - Tests the API endpoint
  • Comprehensive test coverage including edge cases

Function Behavior

  • ✅ Returns true for: "123", "0", "9876543210"
  • ❌ Returns false for: "123abc", "12.34", "12 34", "12-34", ""

API Usage

POST /api/isDigit
{
  "inputString": "12345"
}

Response: {"result": true}

Testing

  • All unit tests pass
  • All integration tests pass
  • Follows existing code style and patterns
  • Maintains backward compatibility

Related Issues

Closes #17 - Add API Call and Function for isDigit

image

@Ujjwal-here Ujjwal-here changed the title Feature/isDigit: Add isDigit utility with unit and integration tests Add isDigit utility with unit and integration tests Aug 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add API Call and Function for isDigit

1 participant