Skip to content

fix(ir): Add support for byte format in string validation#1296

Open
k4n4ry wants to merge 2 commits into
ogen-go:mainfrom
k4n4ry:fix/issue-1261
Open

fix(ir): Add support for byte format in string validation#1296
k4n4ry wants to merge 2 commits into
ogen-go:mainfrom
k4n4ry:fix/issue-1261

Conversation

@k4n4ry

@k4n4ry k4n4ry commented Aug 12, 2024

Copy link
Copy Markdown
Contributor

Fixes #1261

Overview

I've added a new Byte field to the String structure in the validate package.
This field is set to true when format: byte is specified in the string formats of OpenAPI.
When executing character length validation, if the Byte field is true, the length is verified using []byte instead of []rune.

Note

This change may not be necessary.
According to the OpenAPI specification, format: byte is specified for base64-encoded characters.
If the characters used are those in base64 encoding, the length evaluation doesn't change during the []byte -> string -> []rune conversion process.
However, as mentioned in the issue, I suppose this change is necessary if we want to ensure validation behavior for more general bytes fields.

@codecov

codecov Bot commented Aug 12, 2024

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.93%. Comparing base (829c6a4) to head (63919c9).
⚠️ Report is 722 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1296      +/-   ##
==========================================
+ Coverage   73.90%   73.93%   +0.02%     
==========================================
  Files         189      189              
  Lines       12855    12860       +5     
==========================================
+ Hits         9501     9508       +7     
+ Misses       2805     2804       -1     
+ Partials      549      548       -1     

☔ View full report in Codecov by Harness.
📢 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.
@ernado

ernado commented Apr 18, 2025

Copy link
Copy Markdown
Member

I think this should be opt-in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants