1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-11-25 23:52:32 +02:00

added required validator for the TextField.Pattern option in case it is a primary key

This commit is contained in:
Gani Georgiev
2024-11-19 17:21:25 +02:00
parent 48328bf33f
commit 9fe4f87e5b
8 changed files with 31 additions and 9 deletions

View File

@@ -704,7 +704,7 @@ func TestCollectionValidate(t *testing.T) {
collection: func(app core.App) (*core.Collection, error) {
c := core.NewBaseCollection("new_auth")
c.Fields = core.NewFieldsList(
&core.TextField{Name: "id", PrimaryKey: true, Required: true},
&core.TextField{Name: "id", PrimaryKey: true, Required: true, Pattern: `\w+`},
)
return c, nil
},
@@ -715,7 +715,7 @@ func TestCollectionValidate(t *testing.T) {
collection: func(app core.App) (*core.Collection, error) {
c := core.NewBaseCollection("new_auth")
c.Fields = core.NewFieldsList(
&core.TextField{Name: "id", PrimaryKey: true, Required: true},
&core.TextField{Name: "id", PrimaryKey: true, Required: true, Pattern: `\w+`},
&core.TextField{Id: "f1", Name: "Test"}, // case-insensitive
&core.BoolField{Id: "f2", Name: "test"},
)