1
0
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:
Darren Shepherd
2018-07-13 13:05:08 -07:00
parent dca6c2e43d
commit 9324ec8b09

View File

@@ -8,6 +8,7 @@ import (
type Access struct {
Fields map[string]string
Optional bool
}
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 {
for name, access := range e.Fields {
if err := ValidateField(name, schema); err != nil {
if e.Optional {
continue
}
return err
}