-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Hi,
I am new to go, and its highly likely that I don't understand how to make this work, but that its possible. Not sure if its a bug but if anyone has insight it would be super appreciated.
Furthermore, everything seems to work?
I get this in the log output each time the server starts:
2013/07/03 09:47:12 reflect.go:715: Failed to generate name for field.
0 _ast.CallExpr {
1 . Fun: *ast.SelectorExpr {
2 . . X: *ast.Ident {
3 . . . NamePos: 1081
4 . . . Name: "self"
5 . . . Obj: *ast.Object {
6 . . . . Kind: var
7 . . . . Name: "self"
8 . . . . Decl: *ast.Field {
9 . . . . . Names: []_ast.Ident (len = 1) {
10 . . . . . . 0: _ast.Ident {
11 . . . . . . . NamePos: 789
12 . . . . . . . Name: "self"
13 . . . . . . . Obj: *(obj @ 5)
14 . . . . . . }
15 . . . . . }
16 . . . . . Type: *ast.StarExpr {
17 . . . . . . Star: 794
18 . . . . . . X: *ast.Ident {
19 . . . . . . . NamePos: 795
20 . . . . . . . Name: "User"
21 . . . . . . . Obj: *ast.Object {
22 . . . . . . . . Kind: type
23 . . . . . . . . Name: "User"
24 . . . . . . . . Decl: *ast.TypeSpec {
25 . . . . . . . . . Name: *ast.Ident {
26 . . . . . . . . . . NamePos: 127
27 . . . . . . . . . . Name: "User"
28 . . . . . . . . . . Obj: *(obj @ 21)
29 . . . . . . . . . }
30 . . . . . . . . . Type: *ast.StructType {
31 . . . . . . . . . . Struct: 132
32 . . . . . . . . . . Fields: *ast.FieldList {
33 . . . . . . . . . . . Opening: 139
34 . . . . . . . . . . . List: []_ast.Field (len = 4) {
35 . . . . . . . . . . . . 0: _ast.Field {
36 . . . . . . . . . . . . . Names: []_ast.Ident (len = 1) {
37 . . . . . . . . . . . . . . 0: _ast.Ident {
38 . . . . . . . . . . . . . . . NamePos: 143
39 . . . . . . . . . . . . . . . Name: "DisplayName"
40 . . . . . . . . . . . . . . . Obj: *ast.Object {
41 . . . . . . . . . . . . . . . . Kind: var
42 . . . . . . . . . . . . . . . . Name: "DisplayName"
43 . . . . . . . . . . . . . . . . Decl: *(obj @ 35)
44 . . . . . . . . . . . . . . . }
45 . . . . . . . . . . . . . . }
46 . . . . . . . . . . . . . }
47 . . . . . . . . . . . . . Type: *ast.Ident {
48 . . . . . . . . . . . . . . NamePos: 156
49 . . . . . . . . . . . . . . Name: "string"
50 . . . . . . . . . . . . . }
51 . . . . . . . . . . . . }
52 . . . . . . . . . . . . 1: *ast.Field {
53 . . . . . . . . . . . . . Names: []_ast.Ident (len = 1) {
54 . . . . . . . . . . . . . . 0: _ast.Ident {
55 . . . . . . . . . . . . . . . NamePos: 165
56 . . . . . . . . . . . . . . . Name: "Email"
57 . . . . . . . . . . . . . . . Obj: *ast.Object {
58 . . . . . . . . . . . . . . . . Kind: var
59 . . . . . . . . . . . . . . . . Name: "Email"
60 . . . . . . . . . . . . . . . . Decl: *(obj @ 52)
61 . . . . . . . . . . . . . . . }
62 . . . . . . . . . . . . . . }
63 . . . . . . . . . . . . . }
64 . . . . . . . . . . . . . Type: *ast.Ident {
65 . . . . . . . . . . . . . . NamePos: 178
66 . . . . . . . . . . . . . . Name: "string"
67 . . . . . . . . . . . . . }
68 . . . . . . . . . . . . }
69 . . . . . . . . . . . . 2: *ast.Field {
70 . . . . . . . . . . . . . Names: []_ast.Ident (len = 1) {
71 . . . . . . . . . . . . . . 0: _ast.Ident {
72 . . . . . . . . . . . . . . . NamePos: 187
73 . . . . . . . . . . . . . . . Name: "Slug"
74 . . . . . . . . . . . . . . . Obj: *ast.Object {
75 . . . . . . . . . . . . . . . . Kind: var
76 . . . . . . . . . . . . . . . . Name: "Slug"
77 . . . . . . . . . . . . . . . . Decl: *(obj @ 69)
78 . . . . . . . . . . . . . . . }
79 . . . . . . . . . . . . . . }
80 . . . . . . . . . . . . . }
81 . . . . . . . . . . . . . Type: *ast.Ident {
82 . . . . . . . . . . . . . . NamePos: 200
83 . . . . . . . . . . . . . . Name: "string"
84 . . . . . . . . . . . . . }
85 . . . . . . . . . . . . }
86 . . . . . . . . . . . . 3: *ast.Field {
87 . . . . . . . . . . . . . Names: []_ast.Ident (len = 1) {
88 . . . . . . . . . . . . . . 0: *ast.Ident {
89 . . . . . . . . . . . . . . . NamePos: 209
90 . . . . . . . . . . . . . . . Name: "PwdHash"
91 . . . . . . . . . . . . . . . Obj: *ast.Object {
92 . . . . . . . . . . . . . . . . Kind: var
93 . . . . . . . . . . . . . . . . Name: "PwdHash"
94 . . . . . . . . . . . . . . . . Decl: *(obj @ 86)
95 . . . . . . . . . . . . . . . }
96 . . . . . . . . . . . . . . }
97 . . . . . . . . . . . . . }
98 . . . . . . . . . . . . . Type: *ast.ArrayType {
99 . . . . . . . . . . . . . . Lbrack: 221
100 . . . . . . . . . . . . . . Elt: *ast.Ident {
101 . . . . . . . . . . . . . . . NamePos: 223
102 . . . . . . . . . . . . . . . Name: "byte"
103 . . . . . . . . . . . . . . }
104 . . . . . . . . . . . . . }
105 . . . . . . . . . . . . }
106 . . . . . . . . . . . }
107 . . . . . . . . . . . Closing: 228
108 . . . . . . . . . . }
109 . . . . . . . . . . Incomplete: false
110 . . . . . . . . . }
111 . . . . . . . . }
112 . . . . . . . }
113 . . . . . . }
114 . . . . . }
115 . . . . }
116 . . . }
117 . . }
118 . . Sel: *ast.Ident {
119 . . . NamePos: 1086
120 . . . Name: "EmailDoesNotExist"
121 . . }
122 . }
123 . Lparen: 1103
124 . Ellipsis: 0
125 . Rparen: 1104
126 }
This has to do with the validation for email uniqueness I am trying to make happen. (And, is working, fwiw)
app/models/user.go:
type User struct {
DisplayName string
Email string
Slug string
PwdHash []byte
}
func (self *User) Validate(v *revel.Validation) {
// check email sanity
v.Check(self.Email,
revel.Required{},
revel.MaxSize{100},
revel.MinSize{5},
).Key("user.Email")
// if above validations check run the email uniqueness check
if(v.HasErrors() == false) {
v.Required(self.EmailDoesNotExist()).Key("user.Email").Message("Email Already Exists")
}
}
It appears the validation uses some form of code parsing and syntax tree to see what field we are validating, but in this case I am calling a function which checks a database for its email.
Maybe there is a better way to accomplish something such as this?
Thanks !