MCPcopy
hub / github.com/pocketbase/pocketbase / onCollectionValidate

Function onCollectionValidate

core/collection_validate.go:21–42  ·  view source on GitHub ↗
(e *CollectionEvent)

Source from the content-addressed store, hash-verified

19var collectionNameRegex = regexp.MustCompile(`^\w+$`)
20
21func onCollectionValidate(e *CollectionEvent) error {
22 var original *Collection
23 if !e.Collection.IsNew() {
24 original = &Collection{}
25 if err := e.App.ModelQuery(original).Model(e.Collection.LastSavedPK(), original); err != nil {
26 return fmt.Errorf("failed to fetch old collection state: %w", err)
27 }
28 }
29
30 validator := newCollectionValidator(
31 e.Context,
32 e.App,
33 e.Collection,
34 original,
35 )
36
37 if err := validator.run(); err != nil {
38 return err
39 }
40
41 return e.Next()
42}
43
44func newCollectionValidator(ctx context.Context, app App, new, original *Collection) *collectionValidator {
45 validator := &collectionValidator{

Callers

nothing calls this directly

Calls 7

newCollectionValidatorFunction · 0.85
ModelMethod · 0.80
IsNewMethod · 0.65
ModelQueryMethod · 0.65
LastSavedPKMethod · 0.65
runMethod · 0.65
NextMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…