Skip to content

Enhance Hero Endpoint Input Validation#4

Open
xLDVx wants to merge 4 commits into
SammyBryant11:67aa43ad-be87-427c-a430-fc792a400a96from
xLDVx:feature-hero-input-validation-1749254518
Open

Enhance Hero Endpoint Input Validation#4
xLDVx wants to merge 4 commits into
SammyBryant11:67aa43ad-be87-427c-a430-fc792a400a96from
xLDVx:feature-hero-input-validation-1749254518

Conversation

@xLDVx
Copy link
Copy Markdown

@xLDVx xLDVx commented Jun 7, 2025

Enhance Hero Endpoint Input Validation

Description

Task

Add input validation for hero endpoint parameters

Acceptance Criteria

  • Implement input validation for hero names
  • Add validation for search query parameters
  • Provide meaningful error messages
  • Prevent processing of invalid inputs

Summary of Work

This pull request adds robust input validation for hero endpoint parameters to prevent invalid or malicious requests.

Changes Made

  • Enhanced input validation middleware in src/middleware/heroValidation.ts
  • Implemented comprehensive validation for hero names and search queries
  • Added detailed error messages for different validation scenarios

Validation Details

  1. Hero Name Validation:

    • Minimum length: 2 characters
    • Maximum length: 50 characters
    • Allowed characters: Letters, spaces, and hyphens
    • Trims whitespace
    • Provides clear error messages for different validation failures
  2. Hero Search Query Validation:

    • Optional query parameter
    • Minimum length: 2 characters
    • Maximum length: 50 characters
    • Allowed characters: Letters, spaces, and hyphens
    • Provides informative error messages

Validation Rules

  • Prevents empty inputs
  • Restricts input to safe character sets
  • Limits input length to prevent potential DoS attacks
  • Provides user-friendly error messages

Benefits

  • Improved security by sanitizing inputs
  • Consistent error handling
  • Prevents processing of invalid requests
  • Enhanced user experience through clear validation feedback

Testing Approach

  • Validated input validation middleware
  • Tested edge cases and boundary conditions
  • Ensured proper error responses for invalid inputs

Changes Made

  • Updated heroValidation.ts to add comprehensive input validation
  • Added validation schemas for hero names and search queries
  • Implemented middleware to validate and sanitize inputs
  • Created detailed error messages for different validation scenarios

Tests

  • Validate hero name with valid input
  • Validate hero name with invalid characters
  • Validate hero name length constraints
  • Test search query validation with valid input
  • Test search query validation with invalid characters
  • Verify error messages for different validation failures

Signatures

Staking Key

He88p8gayqrGSWqpj7Mu4XzqcKsURDjnuK1z2UMnio3A: 2A9GnwR8FwJP9L7FXc9aGAEUcxYLhQyGYUGTbx8KfhAxyAQmhLw9VPKxarKFYnnyoTB1Peoc257jnjjAQq7pSHzc4xgHGdbYHd5ZEJsujQqiKam1jBJpLaYoqa45K1ikQFqVh7ZcQshKmgY4s6tatdLxgjWrjLPnQneaNe47j9WDYnn3RMt4nbPaKqFXwgFN3f5x7L7geodar7AqdeC9SvByBmzHAcYgfQzAZTLU2Qc1nzigQJw7eukyLSmKWC5KGWpXRsX4654QuCEF7c5NU2Ygbx4UAh1nTa7wJdFB5nTrQMadQmLPK6k4DU1rG9YxnEbGeTcCGicVDPtfu7PWQpFF54Ed6GSaCXytwXiThh4E4mezgXNN5Hhjamv3e6RvNKeYc5gKGbkKRAjExYXkwa341Zrt

Public Key

FVeknmSZKTCvd8fxFxt5T4mQgxED2QhYBZyexLyCrrB8: gR9N13Cy7A1ULzDeBmoDPTEsrNU8N4FzGhoTRctRXFSfdHC1AtbzZRscxQgrEPB1S7iF7MXEzo2iC5JH1VxUkD8918h7HymLzUBN7u87YJ3twvPwpbj9QGSnqBEVb5RoPd9LujzZNdMuTvFnMmYnYMENPEWJuQSXXBJR6oNp7A5suqH5BXjGfE9CfEfuWbjXvHiNdfkSCEB3atYUxNwRroKwMh9gX4uDKdW9dik4q4m9EGv6KFXcaMF1jeg1bZERbS2mpKbvfaKk8b9G1FdeSRb7eHdNkjucBJNdzLFksBi9FjiaVsHChVodnZWw1QS3pak5PziADy54sLiCaD9fKLq1JszV2SU37gGXsmDE8NgdmRPZuFEJJM8rienDN3m4ihuuUBdQyh2aVMeRxDaLWXVyV7r

@xLDVx xLDVx changed the title [WIP] Implement Input Validation for Hero Endpoints Enhance Hero Endpoint Input Validation Jun 7, 2025
@xLDVx xLDVx marked this pull request as ready for review June 7, 2025 00:04
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.

1 participant