Skip to content

Enhance Hero Request Validation and Error Handling#1

Open
Santix1234 wants to merge 6 commits into
SammyBryant11:fbcc6015-7663-40e5-9605-a6f7fbc8bbf5from
Santix1234:hero-request-validation-errors-1749252182
Open

Enhance Hero Request Validation and Error Handling#1
Santix1234 wants to merge 6 commits into
SammyBryant11:fbcc6015-7663-40e5-9605-a6f7fbc8bbf5from
Santix1234:hero-request-validation-errors-1749252182

Conversation

@Santix1234
Copy link
Copy Markdown

@Santix1234 Santix1234 commented Jun 6, 2025

Enhance Hero Request Validation and Error Handling

Description

Task

Add validation and error handling for hero request

Acceptance Criteria

  • Validate hero name input
  • Normalize hero names (trim, lowercase)
  • Handle case-insensitive hero matching
  • Provide meaningful error messages
  • Use appropriate HTTP status codes

Summary of Work

Overview

This pull request implements robust validation and error handling for hero requests, ensuring comprehensive input validation and providing clear, informative error responses.

Key Changes

  • Improved hero name validation in src/validation/heroValidation.js
  • Added detailed error handling for different validation scenarios
  • Created a custom HeroValidationError for consistent error reporting
  • Implemented input sanitization and normalization

Validation Improvements

  1. Input Type Checking

    • Validate that hero name is a non-empty string
    • Trim and normalize input to handle various input formats
    • Case-insensitive hero name matching
  2. Error Handling

    • Throw specific errors for different validation scenarios
    • Use custom HeroValidationError with appropriate status codes
    • Provide clear, descriptive error messages

Testing Approach

  • Validated handling of various input scenarios
  • Tested edge cases like empty strings, whitespace, and non-string inputs
  • Ensured consistent error responses across different input types

Notes

  • Existing implementation extended for better error handling
  • Minimal changes to maintain backward compatibility
  • Improved developer and user experience through clear validation

Changes Made

  • Enhanced validateHeroName function in src/validation/heroValidation.js
  • Added comprehensive input validation checks
  • Implemented case-insensitive hero name normalization
  • Created custom HeroValidationError for consistent error handling
  • Improved error messaging for different validation scenarios

Tests

  • Validate hero name input sanitization
  • Test case-insensitive hero name matching
  • Verify error handling for invalid hero names
  • Check error responses for empty or non-string inputs
  • Ensure consistent error message formatting

Signatures

Staking Key

DKCEYXWcoJrRVt9kB7nXZQkeL2MrNxobmbsWC8R3QWA8: WGhgZu91SLERdeQRjaNQmLANFDBtMWoBzKhGTigFPFJz9KFq97LTu5v4jNm23Wbj6pw6TuwG9dRqFxDR8rTUdpsdQ5oBdHr8pRRSpDmatDZLKcLxSYzkMfm1vsCSkhHaWnEjLJ9X5Eu2gFYN8d7QasgNa55zgq5EF1vn2ymjiN4tizqgTv5K5hXLbgkhZywEgwazL54DdnX4Tk7V2oHXJtCeYor9BpStp8CL7XWY5uyjxKgKZh5jVFSkN5qKPXD3aD6jro5io7W5jhT7ASb7YzzPs8AKGvfqk4cJndxGrJABEH54TYGoMKPfctFNYewPorV1vUHtbz6xLTB1T1F7QYqRq5iQD4JwEdLP9WZfNLvc898S9pkVgKNjzrKvVtoBNruMwGRh1GUh6zmDF5LBobDaiCUHMYwWEQ

Public Key

BLkTvPfFXvR52AK1EoHFaPyE1eDy6Mr5GvgWAbFMvK6x: PkutyySMK13tqKBNb8W2Mgh2yo2nbQepf361p2qDc4KcMrguvvdBMAArWf2AxgZUo54iHBnkqoB3fo22EJEMBWfZdYcDJEgZ5dCyb9S4jD5K1aewYuePX9Rh7V4oY4Edb8cHwmneQzpcnt2ehLY3k7YbAC3yBykoRWhq76PynZwjQSefAWneDs1pjkeMSsJXaVZo8pNaaBMeQGg7roCHgjGsYF8eQ3UBEynYYcx9VaCgPvHMZHFxuWb6WR5tFTaVDGz4pxAckNao7QyyDNbYXs1DuvMiXzer2tNa5DJ6XGhxZQZhzBKSAzpZMQMiSXPuhNPkZ8ALWeK7yyHoYnoY7enWHiqaKJUAtNqDcr7wJqvpwUP3wM6qUZjdYZG96TaKAXxh9dq2h23TAZfqgQwpYUqkJYvocFCfCp

@Santix1234 Santix1234 changed the title [WIP] Implement Hero Request Validation and Error Handling Enhance Hero Request Validation and Error Handling Jun 6, 2025
@Santix1234 Santix1234 marked this pull request as ready for review June 6, 2025 23:25
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