diff --git a/internal/i18n/en_translations.go b/internal/i18n/en_translations.go index 9905330683..681c226848 100644 --- a/internal/i18n/en_translations.go +++ b/internal/i18n/en_translations.go @@ -205,4 +205,5 @@ var ( MsgInvalidIdentity = ffm("FF10285", "Supplied Fabric signer identity is invalid", 400) MsgFailedToDecodeCertificate = ffm("FF10286", "Failed to decode certificate: %s", 500) MsgInvalidMessageType = ffm("FF10287", "Invalid message type - allowed types are %s", 400) + MsgNoUUID = ffm("FF10288", "Field '%s' must not be a UUID", 400) ) diff --git a/pkg/fftypes/validations.go b/pkg/fftypes/validations.go index 4aede21f1b..a895ac0f6e 100644 --- a/pkg/fftypes/validations.go +++ b/pkg/fftypes/validations.go @@ -31,6 +31,10 @@ func ValidateFFNameField(ctx context.Context, str string, fieldName string) erro if !ffNameValidator.MatchString(str) { return i18n.NewError(ctx, i18n.MsgInvalidName, fieldName) } + if _, err := ParseUUID(ctx, str); err == nil { + // Name must not be a UUID + return i18n.NewError(ctx, i18n.MsgNoUUID, fieldName) + } return nil } diff --git a/pkg/fftypes/validations_test.go b/pkg/fftypes/validations_test.go index 6236b71e08..8d4c035e91 100644 --- a/pkg/fftypes/validations_test.go +++ b/pkg/fftypes/validations_test.go @@ -37,6 +37,9 @@ func TestValidateFFNameField(t *testing.T) { err = ValidateFFNameField(context.Background(), "0123456789_123456789-123456789.123456789-123456789_12345678901234", "badField") assert.Regexp(t, "FF10131.*badField", err) + err = ValidateFFNameField(context.Background(), "af34658e-a728-4b21-b9cf-8451f07be065", "badField") + assert.Regexp(t, "FF10288.*badField", err) + } func TestValidateLength(t *testing.T) {