mirror of
https://github.com/rancher/norman.git
synced 2025-09-17 15:49:53 +00:00
Add Optional to access mapper
This commit is contained in:
@@ -7,7 +7,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Access struct {
|
type Access struct {
|
||||||
Fields map[string]string
|
Fields map[string]string
|
||||||
|
Optional bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e Access) FromInternal(data map[string]interface{}) {
|
func (e Access) FromInternal(data map[string]interface{}) {
|
||||||
@@ -20,6 +21,9 @@ func (e Access) ToInternal(data map[string]interface{}) error {
|
|||||||
func (e Access) ModifySchema(schema *types.Schema, schemas *types.Schemas) error {
|
func (e Access) ModifySchema(schema *types.Schema, schemas *types.Schemas) error {
|
||||||
for name, access := range e.Fields {
|
for name, access := range e.Fields {
|
||||||
if err := ValidateField(name, schema); err != nil {
|
if err := ValidateField(name, schema); err != nil {
|
||||||
|
if e.Optional {
|
||||||
|
continue
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user