Skip to content
Snippets Groups Projects
Commit 8bc860ea authored by Semyon Krestyaninov's avatar Semyon Krestyaninov :dog2: Committed by Pavel Antonov
Browse files

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

parent 5910977e
No related branches found
No related tags found
No related merge requests found
......@@ -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)
}
}
}
......
......@@ -199,7 +199,7 @@ func TestFieldNameValidate(t *testing.T) {
{
"Contains hyphen",
"field-name",
true,
false,
},
{
"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