From 8bc860eaf7853659cee929866b8ce378405ddff6 Mon Sep 17 00:00:00 2001 From: Semyon Krestyaninov <krestyaninov@perx.ru> Date: Fri, 19 Apr 2024 08:14:18 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D1=81=D0=B8=D0=BC=D0=B2=D0=BE?= =?UTF-8?q?=D0=BB=20"-"=20=D0=B2=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=D1=85=20=D0=BF=D0=BE=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/schema/field/object.go | 4 ++-- pkg/schema/field/object_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/schema/field/object.go b/pkg/schema/field/object.go index d86aa235..83d234cd 100644 --- a/pkg/schema/field/object.go +++ b/pkg/schema/field/object.go @@ -12,7 +12,7 @@ import ( ) var objectType = &ObjectType{} -var isValidName = regexp.MustCompile(`^[a-zA-Z][\w]*$`).MatchString +var isValidName = regexp.MustCompile(`^[a-zA-Z][\w-]*$`).MatchString type ObjectParameters struct { Inline bool `json:"inline"` @@ -219,7 +219,7 @@ func (ObjectType) ValidateParameters(p Parameters) error { for k := range params.Fields { if !isValidName(k) { return fmt.Errorf("field name '%s' must be in Latin, must not start with a number, "+ - "must not contain spaces - only characters '_' can be used", k) + "must not contain spaces - only characters '_' or '-' can be used", k) } } } diff --git a/pkg/schema/field/object_test.go b/pkg/schema/field/object_test.go index 2ada594b..0dc179a7 100644 --- a/pkg/schema/field/object_test.go +++ b/pkg/schema/field/object_test.go @@ -199,7 +199,7 @@ func TestFieldNameValidate(t *testing.T) { { "Contains hyphen", "field-name", - true, + false, }, { "Contains underscore (success)", -- GitLab