/
runtime.go
86 lines (82 loc) · 4.35 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
// Code generated by ent, DO NOT EDIT.
package ent
import (
"time"
"github.com/go-lynx/lynx-layout/internal/data/ent/schema"
"github.com/go-lynx/lynx-layout/internal/data/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() {
userFields := schema.User{}.Fields()
_ = userFields
// userDescNum is the schema descriptor for num field.
userDescNum := userFields[1].Descriptor()
// user.NumValidator is a validator for the "num" field. It is called by the builders before save.
user.NumValidator = userDescNum.Validators[0].(func(string) error)
// userDescAccount is the schema descriptor for account field.
userDescAccount := userFields[2].Descriptor()
// user.DefaultAccount holds the default value on creation for the account field.
user.DefaultAccount = userDescAccount.Default.(string)
// user.AccountValidator is a validator for the "account" field. It is called by the builders before save.
user.AccountValidator = userDescAccount.Validators[0].(func(string) error)
// userDescPassword is the schema descriptor for password field.
userDescPassword := userFields[3].Descriptor()
// user.DefaultPassword holds the default value on creation for the password field.
user.DefaultPassword = userDescPassword.Default.(string)
// 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)
// userDescPhone is the schema descriptor for phone field.
userDescPhone := userFields[4].Descriptor()
// user.DefaultPhone holds the default value on creation for the phone field.
user.DefaultPhone = userDescPhone.Default.(string)
// user.PhoneValidator is a validator for the "phone" field. It is called by the builders before save.
user.PhoneValidator = userDescPhone.Validators[0].(func(string) error)
// userDescNickname is the schema descriptor for nickname field.
userDescNickname := userFields[5].Descriptor()
// user.NicknameValidator is a validator for the "nickname" field. It is called by the builders before save.
user.NicknameValidator = func() func(string) error {
validators := userDescNickname.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(nickname string) error {
for _, fn := range fns {
if err := fn(nickname); err != nil {
return err
}
}
return nil
}
}()
// userDescAvatar is the schema descriptor for avatar field.
userDescAvatar := userFields[6].Descriptor()
// user.DefaultAvatar holds the default value on creation for the avatar field.
user.DefaultAvatar = userDescAvatar.Default.(string)
// user.AvatarValidator is a validator for the "avatar" field. It is called by the builders before save.
user.AvatarValidator = userDescAvatar.Validators[0].(func(string) error)
// userDescStats is the schema descriptor for stats field.
userDescStats := userFields[7].Descriptor()
// user.DefaultStats holds the default value on creation for the stats field.
user.DefaultStats = userDescStats.Default.(int32)
// userDescNote is the schema descriptor for note field.
userDescNote := userFields[8].Descriptor()
// user.DefaultNote holds the default value on creation for the note field.
user.DefaultNote = userDescNote.Default.(string)
// user.NoteValidator is a validator for the "note" field. It is called by the builders before save.
user.NoteValidator = userDescNote.Validators[0].(func(string) error)
// userDescCreatedAt is the schema descriptor for created_at field.
userDescCreatedAt := userFields[11].Descriptor()
// user.DefaultCreatedAt holds the default value on creation for the created_at field.
user.DefaultCreatedAt = userDescCreatedAt.Default.(func() time.Time)
// userDescUpdatedAt is the schema descriptor for updated_at field.
userDescUpdatedAt := userFields[12].Descriptor()
// user.DefaultUpdatedAt holds the default value on creation for the updated_at field.
user.DefaultUpdatedAt = userDescUpdatedAt.Default.(func() time.Time)
// userDescID is the schema descriptor for id field.
userDescID := userFields[0].Descriptor()
// user.IDValidator is a validator for the "id" field. It is called by the builders before save.
user.IDValidator = userDescID.Validators[0].(func(int64) error)
}