-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtime.go
105 lines (101 loc) · 4.07 KB
/
runtime.go
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Code generated by entc, DO NOT EDIT.
package ent
import (
"time"
"github.com/gibalmeida/go-jobs/ent/department"
"github.com/gibalmeida/go-jobs/ent/job"
"github.com/gibalmeida/go-jobs/ent/schema"
"github.com/gibalmeida/go-jobs/ent/user"
)
// 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() {
departmentFields := schema.Department{}.Fields()
_ = departmentFields
// departmentDescName is the schema descriptor for name field.
departmentDescName := departmentFields[0].Descriptor()
// department.NameValidator is a validator for the "name" field. It is called by the builders before save.
department.NameValidator = departmentDescName.Validators[0].(func(string) error)
jobFields := schema.Job{}.Fields()
_ = jobFields
// jobDescName is the schema descriptor for name field.
jobDescName := jobFields[0].Descriptor()
// job.NameValidator is a validator for the "name" field. It is called by the builders before save.
job.NameValidator = func() func(string) error {
validators := jobDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
validators[2].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// jobDescDescription is the schema descriptor for description field.
jobDescDescription := jobFields[1].Descriptor()
// job.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
job.DescriptionValidator = func() func(string) error {
validators := jobDescDescription.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(description string) error {
for _, fn := range fns {
if err := fn(description); err != nil {
return err
}
}
return nil
}
}()
userMixin := schema.User{}.Mixin()
userMixinFields0 := userMixin[0].Fields()
_ = userMixinFields0
userFields := schema.User{}.Fields()
_ = userFields
// userDescCreateTime is the schema descriptor for create_time field.
userDescCreateTime := userMixinFields0[0].Descriptor()
// user.DefaultCreateTime holds the default value on creation for the create_time field.
user.DefaultCreateTime = userDescCreateTime.Default.(func() time.Time)
// userDescUpdateTime is the schema descriptor for update_time field.
userDescUpdateTime := userMixinFields0[1].Descriptor()
// user.DefaultUpdateTime holds the default value on creation for the update_time field.
user.DefaultUpdateTime = userDescUpdateTime.Default.(func() time.Time)
// user.UpdateDefaultUpdateTime holds the default value on update for the update_time field.
user.UpdateDefaultUpdateTime = userDescUpdateTime.UpdateDefault.(func() time.Time)
// userDescName is the schema descriptor for name field.
userDescName := userFields[0].Descriptor()
// user.NameValidator is a validator for the "name" field. It is called by the builders before save.
user.NameValidator = func() func(string) error {
validators := userDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
validators[2].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// userDescEmail is the schema descriptor for email field.
userDescEmail := userFields[1].Descriptor()
// user.EmailValidator is a validator for the "email" field. It is called by the builders before save.
user.EmailValidator = userDescEmail.Validators[0].(func(string) error)
// userDescPassword is the schema descriptor for password field.
userDescPassword := userFields[2].Descriptor()
// user.PasswordValidator is a validator for the "password" field. It is called by the builders before save.
user.PasswordValidator = userDescPassword.Validators[0].(func(string) error)
}