mirror of
https://github.com/rancher/norman.git
synced 2025-08-01 07:21:07 +00:00
Add InputFormatter that runs before the builder/validation
This commit is contained in:
parent
16ed673d50
commit
f33accee7c
@ -27,6 +27,12 @@ func ParseAndValidateBody(apiContext *types.APIContext, create bool) (map[string
|
||||
if !create {
|
||||
op = builder.Update
|
||||
}
|
||||
if apiContext.Schema.InputFormatter != nil {
|
||||
err = apiContext.Schema.InputFormatter(apiContext, apiContext.Schema, data, create)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
data, err = b.Construct(apiContext.Schema, data, op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -69,6 +69,8 @@ type QueryFilter func(opts *QueryOptions, schema *Schema, data []map[string]inte
|
||||
|
||||
type Validator func(request *APIContext, schema *Schema, data map[string]interface{}) error
|
||||
|
||||
type InputFormatter func(request *APIContext, schema *Schema, data map[string]interface{}, create bool) error
|
||||
|
||||
type Formatter func(request *APIContext, resource *RawResource)
|
||||
|
||||
type CollectionFormatter func(request *APIContext, collection *GenericCollection)
|
||||
|
@ -111,6 +111,7 @@ type Schema struct {
|
||||
CreateHandler RequestHandler `json:"-"`
|
||||
DeleteHandler RequestHandler `json:"-"`
|
||||
UpdateHandler RequestHandler `json:"-"`
|
||||
InputFormatter InputFormatter `json:"-"`
|
||||
Formatter Formatter `json:"-"`
|
||||
CollectionFormatter CollectionFormatter `json:"-"`
|
||||
ErrorHandler ErrorHandler `json:"-"`
|
||||
|
Loading…
Reference in New Issue
Block a user