MCPcopy
hub / github.com/pocketbase/pocketbase / validateCollectionId

Function validateCollectionId

core/db.go:450–471  ·  view source on GitHub ↗
(app App, optTypes ...string)

Source from the content-addressed store, hash-verified

448}
449
450func validateCollectionId(app App, optTypes ...string) validation.RuleFunc {
451 return func(value any) error {
452 id, _ := value.(string)
453 if id == "" {
454 return nil
455 }
456
457 collection := &Collection{}
458 if err := app.ModelQuery(collection).Model(id, collection); err != nil {
459 return validation.NewError("validation_invalid_collection_id", "Missing or invalid collection.")
460 }
461
462 if len(optTypes) > 0 && !slices.Contains(optTypes, collection.Type) {
463 return validation.NewError(
464 "validation_invalid_collection_type",
465 fmt.Sprintf("Invalid collection type - must be %s.", strings.Join(optTypes, ", ")),
466 )
467 }
468
469 return nil
470 }
471}
472
473func validateRecordId(app App, collectionNameOrId string) validation.RuleFunc {
474 return func(value any) error {

Callers 1

recordRefHooksFunction · 0.85

Calls 2

ModelMethod · 0.80
ModelQueryMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…