mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-09-17 03:50:54 +02:00
added topic length validator to avoid relying solely on the body limit for more user friendly error message
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
## v0.22.23
|
||||
|
||||
-
|
||||
|
||||
- Other minor fixes (updated npm deps to fix the vulnerabilities warning, more user friendly realtime topic length error, regenerated JSVM types, etc.)
|
||||
|
||||
|
||||
## v0.22.22
|
||||
|
||||
- Added deprecation log in case Instagram OAuth2 is used (_related to [#5652](https://github.com/pocketbase/pocketbase/discussions/5652)_).
|
||||
|
||||
@@ -19,6 +19,9 @@ func NewRealtimeSubscribe() *RealtimeSubscribe {
|
||||
func (form *RealtimeSubscribe) Validate() error {
|
||||
return validation.ValidateStruct(form,
|
||||
validation.Field(&form.ClientId, validation.Required, validation.Length(1, 255)),
|
||||
validation.Field(&form.Subscriptions, validation.Length(0, 1000)),
|
||||
validation.Field(&form.Subscriptions,
|
||||
validation.Length(0, 1000),
|
||||
validation.Each(validation.Length(0, 2500)),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -43,15 +43,25 @@ func TestRealtimeSubscribeValidate(t *testing.T) {
|
||||
[]string{},
|
||||
},
|
||||
{
|
||||
"subscriptions > max limit",
|
||||
"total subscriptions > max limit",
|
||||
`{"clientId":"test", "subscriptions":[` + strings.Join(invalidSubscriptionsLimit, ",") + `]}`,
|
||||
[]string{"subscriptions"},
|
||||
},
|
||||
{
|
||||
"subscriptions <= max limit",
|
||||
"total subscriptions <= max limit",
|
||||
`{"clientId":"test", "subscriptions":[` + strings.Join(validSubscriptionsLimit, ",") + `]}`,
|
||||
[]string{},
|
||||
},
|
||||
{
|
||||
"single subscription > max limit",
|
||||
`{"clientId":"test", "subscriptions":["abc", "` + strings.Repeat("a", 2501) + `"]}`,
|
||||
[]string{"subscriptions"},
|
||||
},
|
||||
{
|
||||
"single subscription <= max limit",
|
||||
`{"clientId":"test", "subscriptions":["abc", "` + strings.Repeat("a", 2500) + `"]}`,
|
||||
[]string{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, s := range scenarios {
|
||||
|
||||
Reference in New Issue
Block a user