File: runtime.go

package info (click to toggle)
golang-github-facebook-ent 0.5.4-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,284 kB
  • sloc: javascript: 349; makefile: 8
file content (78 lines) | stat: -rw-r--r-- 3,323 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright 2019-present Facebook Inc. All rights reserved.
// This source code is licensed under the Apache 2.0 license found
// in the LICENSE file in the root directory of this source tree.

// Code generated by entc, DO NOT EDIT.

package ent

import (
	"github.com/facebook/ent/entc/integration/customid/ent/blob"
	"github.com/facebook/ent/entc/integration/customid/ent/car"
	"github.com/facebook/ent/entc/integration/customid/ent/mixinid"
	"github.com/facebook/ent/entc/integration/customid/ent/pet"
	"github.com/facebook/ent/entc/integration/customid/ent/schema"
	"github.com/google/uuid"
)

// The init function reads all schema descriptors with runtime code
// (default values, validators, hooks and policies) and stitches it
// to their package variables.
func init() {
	blobFields := schema.Blob{}.Fields()
	_ = blobFields
	// blobDescUUID is the schema descriptor for uuid field.
	blobDescUUID := blobFields[1].Descriptor()
	// blob.DefaultUUID holds the default value on creation for the uuid field.
	blob.DefaultUUID = blobDescUUID.Default.(func() uuid.UUID)
	// blobDescID is the schema descriptor for id field.
	blobDescID := blobFields[0].Descriptor()
	// blob.DefaultID holds the default value on creation for the id field.
	blob.DefaultID = blobDescID.Default.(func() uuid.UUID)
	carMixin := schema.Car{}.Mixin()
	carMixinFields0 := carMixin[0].Fields()
	_ = carMixinFields0
	carFields := schema.Car{}.Fields()
	_ = carFields
	// carDescBeforeID is the schema descriptor for before_id field.
	carDescBeforeID := carMixinFields0[0].Descriptor()
	// car.BeforeIDValidator is a validator for the "before_id" field. It is called by the builders before save.
	car.BeforeIDValidator = carDescBeforeID.Validators[0].(func(float64) error)
	// carDescAfterID is the schema descriptor for after_id field.
	carDescAfterID := carMixinFields0[2].Descriptor()
	// car.AfterIDValidator is a validator for the "after_id" field. It is called by the builders before save.
	car.AfterIDValidator = carDescAfterID.Validators[0].(func(float64) error)
	// carDescID is the schema descriptor for id field.
	carDescID := carMixinFields0[1].Descriptor()
	// car.IDValidator is a validator for the "id" field. It is called by the builders before save.
	car.IDValidator = carDescID.Validators[0].(func(int) error)
	mixinidMixin := schema.MixinID{}.Mixin()
	mixinidMixinFields0 := mixinidMixin[0].Fields()
	_ = mixinidMixinFields0
	mixinidFields := schema.MixinID{}.Fields()
	_ = mixinidFields
	// mixinidDescID is the schema descriptor for id field.
	mixinidDescID := mixinidMixinFields0[0].Descriptor()
	// mixinid.DefaultID holds the default value on creation for the id field.
	mixinid.DefaultID = mixinidDescID.Default.(func() uuid.UUID)
	petFields := schema.Pet{}.Fields()
	_ = petFields
	// petDescID is the schema descriptor for id field.
	petDescID := petFields[0].Descriptor()
	// pet.IDValidator is a validator for the "id" field. It is called by the builders before save.
	pet.IDValidator = func() func(string) error {
		validators := petDescID.Validators
		fns := [...]func(string) error{
			validators[0].(func(string) error),
			validators[1].(func(string) error),
		}
		return func(id string) error {
			for _, fn := range fns {
				if err := fn(id); err != nil {
					return err
				}
			}
			return nil
		}
	}()
}