Skip to content

feat: add advanced input validation#6

Merged
allisson merged 1 commit intomainfrom
validation
Jan 24, 2026
Merged

feat: add advanced input validation#6
allisson merged 1 commit intomainfrom
validation

Conversation

@allisson
Copy link
Owner

Integrate the jellydator/validation library for comprehensive input validation across DTOs and use case layers, with custom validation rules for password strength, email format, and whitespace handling.

Changes:

  • Add jellydator/validation v1.2.0 dependency
  • Create internal/validation package with custom validation rules:
    • PasswordStrength: configurable password complexity validation
    • Email: regex-based email format validation
    • NoWhitespace: prevent leading/trailing whitespace
    • NotBlank: ensure non-empty strings after trimming
    • WrapValidationError: helper to convert validation errors to domain errors
  • Update RegisterUserRequest DTO validation with:
    • Name: required, not blank, 1-255 characters
    • Email: required, valid format, 5-255 characters
    • Password: 8-128 chars, uppercase, lowercase, number, special character
  • Update use case input validation with same comprehensive rules
  • Validation errors wrapped as domain ErrInvalidInput (422 status)
  • Add comprehensive test suite for all validation rules (100% coverage)
  • Update test fixtures to use valid passwords meeting new requirements
  • Update README.md with:
    • Input validation feature in features list
    • Validation package in project structure
    • Password requirements and validation error examples in usage section
    • New "Input Validation" section with detailed documentation
    • jellydator/validation in dependencies and acknowledgments

Benefits:

  • Declarative and type-safe validation rules
  • Reusable custom validators across the application
  • Consistent validation at DTO and use case layers
  • User-friendly error messages for API clients
  • Enhanced security with password strength requirements
  • Better data quality with format and constraint validation

Integrate the jellydator/validation library for comprehensive input validation
across DTOs and use case layers, with custom validation rules for password
strength, email format, and whitespace handling.

Changes:
- Add jellydator/validation v1.2.0 dependency
- Create internal/validation package with custom validation rules:
  - PasswordStrength: configurable password complexity validation
  - Email: regex-based email format validation
  - NoWhitespace: prevent leading/trailing whitespace
  - NotBlank: ensure non-empty strings after trimming
  - WrapValidationError: helper to convert validation errors to domain errors
- Update RegisterUserRequest DTO validation with:
  - Name: required, not blank, 1-255 characters
  - Email: required, valid format, 5-255 characters
  - Password: 8-128 chars, uppercase, lowercase, number, special character
- Update use case input validation with same comprehensive rules
- Validation errors wrapped as domain ErrInvalidInput (422 status)
- Add comprehensive test suite for all validation rules (100% coverage)
- Update test fixtures to use valid passwords meeting new requirements
- Update README.md with:
  - Input validation feature in features list
  - Validation package in project structure
  - Password requirements and validation error examples in usage section
  - New "Input Validation" section with detailed documentation
  - jellydator/validation in dependencies and acknowledgments

Benefits:
- Declarative and type-safe validation rules
- Reusable custom validators across the application
- Consistent validation at DTO and use case layers
- User-friendly error messages for API clients
- Enhanced security with password strength requirements
- Better data quality with format and constraint validation
@allisson allisson merged commit e781408 into main Jan 24, 2026
1 check passed
@allisson allisson deleted the validation branch January 24, 2026 15:23
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