From 601180a76a4cabad088cef277240f74ecda2e7fe Mon Sep 17 00:00:00 2001 From: Artem Date: Sun, 3 Sep 2023 17:30:34 +0400 Subject: [PATCH] Fix: Remove bytes prefix --- internal/bcd/ast/validators.go | 5 ++--- internal/bcd/ast/validators_test.go | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/bcd/ast/validators.go b/internal/bcd/ast/validators.go index 47b2f96d2..27d73111f 100644 --- a/internal/bcd/ast/validators.go +++ b/internal/bcd/ast/validators.go @@ -23,8 +23,7 @@ type ValidatorConstraint interface { type Validator[T ValidatorConstraint] func(T) error var ( - hexRegex = regexp.MustCompile("^[0-9a-fA-F]+$") - hexWithPrefixRegex = regexp.MustCompile("^(0x)?[0-9a-fA-F]+$") + hexRegex = regexp.MustCompile("^[0-9a-fA-F]+$") ) // AddressValidator - @@ -125,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 value != "" && !hexWithPrefixRegex.MatchString(value) { + if value != "" && !hexRegex.MatchString(value) { return errors.Wrapf(ErrValidation, "bytes '%s' should be hexademical without prefixes", value) } return nil diff --git a/internal/bcd/ast/validators_test.go b/internal/bcd/ast/validators_test.go index 4d61fbd31..51fbfe9fb 100644 --- a/internal/bcd/ast/validators_test.go +++ b/internal/bcd/ast/validators_test.go @@ -124,7 +124,7 @@ func TestBytesValidator(t *testing.T) { }, { name: "test 3", value: "0x030ed412d33412ab4b71df0aaba07df7ddd2a44eb55c87bf81868ba09a358bc0e0", - wantErr: false, + wantErr: true, }, { name: "test 4", value: "",