(all bool)
| 926 | } |
| 927 | |
| 928 | func (m *SchemaDefinition) validate(all bool) error { |
| 929 | if m == nil { |
| 930 | return nil |
| 931 | } |
| 932 | |
| 933 | var errors []error |
| 934 | |
| 935 | { |
| 936 | sorted_keys := make([]string, len(m.GetEntityDefinitions())) |
| 937 | i := 0 |
| 938 | for key := range m.GetEntityDefinitions() { |
| 939 | sorted_keys[i] = key |
| 940 | i++ |
| 941 | } |
| 942 | sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) |
| 943 | for _, key := range sorted_keys { |
| 944 | val := m.GetEntityDefinitions()[key] |
| 945 | _ = val |
| 946 | |
| 947 | // no validation rules for EntityDefinitions[key] |
| 948 | |
| 949 | if all { |
| 950 | switch v := interface{}(val).(type) { |
| 951 | case interface{ ValidateAll() error }: |
| 952 | if err := v.ValidateAll(); err != nil { |
| 953 | errors = append(errors, SchemaDefinitionValidationError{ |
| 954 | field: fmt.Sprintf("EntityDefinitions[%v]", key), |
| 955 | reason: "embedded message failed validation", |
| 956 | cause: err, |
| 957 | }) |
| 958 | } |
| 959 | case interface{ Validate() error }: |
| 960 | if err := v.Validate(); err != nil { |
| 961 | errors = append(errors, SchemaDefinitionValidationError{ |
| 962 | field: fmt.Sprintf("EntityDefinitions[%v]", key), |
| 963 | reason: "embedded message failed validation", |
| 964 | cause: err, |
| 965 | }) |
| 966 | } |
| 967 | } |
| 968 | } else if v, ok := interface{}(val).(interface{ Validate() error }); ok { |
| 969 | if err := v.Validate(); err != nil { |
| 970 | return SchemaDefinitionValidationError{ |
| 971 | field: fmt.Sprintf("EntityDefinitions[%v]", key), |
| 972 | reason: "embedded message failed validation", |
| 973 | cause: err, |
| 974 | } |
| 975 | } |
| 976 | } |
| 977 | |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | { |
| 982 | sorted_keys := make([]string, len(m.GetRuleDefinitions())) |
| 983 | i := 0 |
| 984 | for key := range m.GetRuleDefinitions() { |
| 985 | sorted_keys[i] = key |
no test coverage detected