Skip to content

Added support for validating private fields - #16

Merged
alexaandru merged 1 commit into
mainfrom
validate-private
Nov 11, 2025
Merged

alexaandru merged 1 commit into
mainfrom
validate-private

Conversation

@alexaandru

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds support for validating private (unexported) struct fields by introducing a new Interface function that works around Go's reflection limitations. The key change removes the ErrorOnPrivate flag and the associated ErrPrivateField error, allowing private fields with validation tags to be validated automatically.

  • Adds Interface helper function to extract values from private fields using reflection
  • Removes ErrorOnPrivate configuration option and ErrPrivateField error
  • Updates all validation checkers to use Interface instead of direct reflect.Value.Interface() calls
  • Adds comprehensive test coverage for private field validation

Reviewed Changes

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

Show a summary per file
File Description
vali.go Removes ErrorOnPrivate field, adds Interface function for private field access, removes private field error handling in validation logic
check.go Updates all checker functions to use Interface helper, removes ErrPrivateField error, improves type handling in luhn and sizeCmp functions
vali_test.go Adds extensive test cases for private field validation, adds TestInterface function to verify the Interface helper
example_test.go Updates example to demonstrate private field validation instead of the removed ErrorOnPrivate feature
README.md Updates documentation to reflect support for private field validation, removes ErrorOnPrivate examples
go.mod, tools/go.mod, tools/go.sum Updates Go version to 1.25.4 and updates various tool dependencies
coverage-badge.svg Adds coverage badge showing 97.4% test coverage
Makefile Updates formatting commands and adds coverage badge generation
.golangci.yml Configuration updates including line length increase and linter adjustments

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

@alexaandru
alexaandru merged commit 3f965ee into main Nov 11, 2025
4 of 5 checks passed
@alexaandru
alexaandru deleted the validate-private branch November 11, 2025 17:15
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.

2 participants