Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,25 @@ func (s *EnumSchema) Prop(key string) (interface{}, bool) {
}

// Validate checks whether the given value is writeable to this schema.
func (*EnumSchema) Validate(v reflect.Value) bool {
//TODO implement
func (s *EnumSchema) Validate(v reflect.Value) bool {
//WARNING cuz only ptr could
if v.Kind() != reflect.Ptr {
if v.CanAddr() == false {
return false
}
v = v.Addr()
}
ret := v.MethodByName("GetIndex").Call([]reflect.Value{})
if len(ret) == 0 {
return false
}
index := ret[0].Interface().(int32)
if index < 0 {
return false
}
if index >= int32(len(s.Symbols)) {
return false
}
return true
}

Expand Down