ogen icon indicating copy to clipboard operation
ogen copied to clipboard

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

Open k4n4ry opened this issue 1 year ago • 2 comments

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.

k4n4ry avatar Aug 12 '24 14:08 k4n4ry

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 73.93%. Comparing base (12fe015) to head (63919c9). Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1296      +/-   ##
==========================================
+ Coverage   73.92%   73.93%   +0.01%     
==========================================
  Files         189      189              
  Lines       12855    12860       +5     
==========================================
+ Hits         9503     9508       +5     
  Misses       2804     2804              
  Partials      548      548              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Aug 12 '24 14:08 codecov[bot]

I think this should be opt-in.

ernado avatar Apr 18 '25 17:04 ernado