mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
added wrapper on models; changed handlers; fixes
This commit is contained in:
32
api/models/app_wrapper.go
Normal file
32
api/models/app_wrapper.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package models
|
||||
|
||||
import "github.com/go-openapi/errors"
|
||||
|
||||
type AppWrapper struct {
|
||||
App *App `json:"app"`
|
||||
}
|
||||
|
||||
func (m *AppWrapper) Validate() error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateApp(); err != nil {
|
||||
// prop
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AppWrapper) validateApp() error {
|
||||
|
||||
if m.App != nil {
|
||||
if err := m.App.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user