Validate after everything is applied.

Fixes #27.
This commit is contained in:
Alec Thomas
2019-06-21 12:09:04 +10:00
parent 95de7d2f0d
commit 102a975844
4 changed files with 20 additions and 8 deletions
+1 -1
View File
@@ -135,7 +135,7 @@ func (c *Context) Validate() error {
err := Visit(c.Model, func(node Visitable, next Next) error {
if value, ok := node.(*Value); ok {
if value.Enum != "" && !value.EnumMap()[fmt.Sprintf("%v", value.Target.Interface())] {
return fmt.Errorf("%s must be one of %s but got %q", value.Summary(), value.Enum, value.Target.Interface())
return fmt.Errorf("%s must be one of %s but got %q", value.ShortSummary(), value.Enum, value.Target.Interface())
}
}
return next(nil)