resources: Improve composition of Validate API in resources

This now appropriately calls the Base method.
This commit is contained in:
James Shubin
2017-01-16 19:28:00 -05:00
parent 51c83116a2
commit 2a6df875ec
13 changed files with 31 additions and 11 deletions

View File

@@ -106,6 +106,17 @@ specifications, it should generate an error. If you notice that this method is
quite large, it might be an indication that you should reconsider the parameter
list and interface to this resource. This method is called _before_ `Init`.
#### Example
```golang
// Validate reports any problems with the struct definition.
func (obj *FooRes) Validate() error {
if obj.Answer != 42 { // validate whatever you want
return fmt.Errorf("expected an answer of 42")
}
return obj.BaseRes.Validate() // remember to call the base method!
}
```
### Init
```golang
Init() error