Skip to content

Conversation

@Nivl
Copy link

@Nivl Nivl commented Jan 18, 2026

What

This PR doesn't update any actual logic.

Here's a list of changes:

  • Add helpers.SecurityValidation and update the code to use it
  • Add helpers.DocumentValidation and update the code to use it
  • Add helpers.PathValidation and separate it from ParameterValidationPath since they are technically a different things.
  • Add helpers.ValidationMissing and update the code to use it
  • Add helpers.ValidationMissingOperation and update the code to use it.
    • This one replaces RequestMissingOperation. Using RequestMissingOperation will trigger a linter error such as this one.
  • Update parts of the code to use already existing constants instead of hardcoded strings

Why

This is to make it safer to use the library by being able to write code such as:

switch validationError.ValidationType {
case validationHelpers.SecurityValidation:
	// do something
case validationHelpers.ParameterValidation:
	// do something else
// ...
}

Copilot AI review requested due to automatic review settings January 18, 2026 05:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the codebase to introduce and use string constants for validation types, making the code more maintainable and enabling safer type-based switching in client code.

Changes:

  • Added SecurityValidation and DocumentValidation constants to helpers/constants.go
  • Replaced hardcoded validation type strings with constants throughout the codebase
  • Updated test files to use the new constants for consistency

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
helpers/constants.go Adds two new exported constants: SecurityValidation and DocumentValidation
validator.go Updates document validation error to use helpers.DocumentValidation constant
validator_test.go Replaces hardcoded validation type strings with constants in test assertions and error creation
schema_validation/validate_document.go Updates schema validation errors to use helpers.Schema constant
schema_validation/validate_document_test.go Updates test to use helpers.Schema constant
parameters/validate_security.go Replaces hardcoded "security" strings with helpers.SecurityValidation constant
errors/validation_error_test.go Updates tests to use helpers.ParameterValidationPath constant and adds helpers import

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Jan 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.58%. Comparing base (cadff75) to head (7f3f907).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #219   +/-   ##
=======================================
  Coverage   97.58%   97.58%           
=======================================
  Files          56       56           
  Lines        5176     5176           
=======================================
  Hits         5051     5051           
  Misses        125      125           
Flag Coverage Δ
unittests 97.58% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Nivl Nivl force-pushed the ml/refactor/security/add-constant-SecurityValidation branch from a0d862a to e8de77e Compare January 18, 2026 06:49
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