Skip to content

Commit

Permalink
Fix: add empty string to valid bytes sequence (#970)
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky authored Mar 26, 2023
1 parent 2cf9420 commit 8f2a9f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/bcd/ast/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func BytesValidator(value string) error {
if len(value)%2 > 0 {
return errors.Wrapf(ErrValidation, "invalid bytes in hex length '%s'", value)
}
if !hexRegex.MatchString(value) {
if value != "" && !hexRegex.MatchString(value) {
return errors.Wrapf(ErrValidation, "bytes '%s' should be hexademical without prefixes", value)
}
return nil
Expand Down
4 changes: 4 additions & 0 deletions internal/bcd/ast/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ func TestBytesValidator(t *testing.T) {
name: "test 3",
value: "0x030ed412d33412ab4b71df0aaba07df7ddd2a44eb55c87bf81868ba09a358bc0e0",
wantErr: true,
}, {
name: "test 4",
value: "",
wantErr: false,
},
}
for _, tt := range tests {
Expand Down

0 comments on commit 8f2a9f0

Please sign in to comment.