Skip to content
Snippets Groups Projects
Commit 66b02b9a authored by Pavel Antonov's avatar Pavel Antonov :asterisk:
Browse files

feat(core): Добавлена возможность использовать символ "-" в названиях полей

Close #PRXS-1439
parents d13399fd 8bc860ea
Loading
...@@ -12,7 +12,7 @@ import ( ...@@ -12,7 +12,7 @@ import (
) )
var objectType = &ObjectType{} var objectType = &ObjectType{}
var isValidName = regexp.MustCompile(`^[a-zA-Z][\w]*$`).MatchString var isValidName = regexp.MustCompile(`^[a-zA-Z][\w-]*$`).MatchString
type ObjectParameters struct { type ObjectParameters struct {
Inline bool `json:"inline"` Inline bool `json:"inline"`
...@@ -219,7 +219,7 @@ func (ObjectType) ValidateParameters(p Parameters) error { ...@@ -219,7 +219,7 @@ func (ObjectType) ValidateParameters(p Parameters) error {
for k := range params.Fields { for k := range params.Fields {
if !isValidName(k) { if !isValidName(k) {
return fmt.Errorf("field name '%s' must be in Latin, must not start with a number, "+ 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)
} }
} }
} }
......
...@@ -199,7 +199,7 @@ func TestFieldNameValidate(t *testing.T) { ...@@ -199,7 +199,7 @@ func TestFieldNameValidate(t *testing.T) {
{ {
"Contains hyphen", "Contains hyphen",
"field-name", "field-name",
true, false,
}, },
{ {
"Contains underscore (success)", "Contains underscore (success)",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment