ValidateFields checks the field values on MACState with the rules defined in the proto definition for this message. If any rules are violated, an error is returned.
(paths ...string)
| 2680 | // the proto definition for this message. If any rules are violated, an error |
| 2681 | // is returned. |
| 2682 | func (m *MACState) ValidateFields(paths ...string) error { |
| 2683 | if m == nil { |
| 2684 | return nil |
| 2685 | } |
| 2686 | |
| 2687 | if len(paths) == 0 { |
| 2688 | paths = MACStateFieldPathsNested |
| 2689 | } |
| 2690 | |
| 2691 | for name, subs := range _processPaths(append(paths[:0:0], paths...)) { |
| 2692 | _ = subs |
| 2693 | switch name { |
| 2694 | case "current_parameters": |
| 2695 | |
| 2696 | if m.GetCurrentParameters() == nil { |
| 2697 | return MACStateValidationError{ |
| 2698 | field: "current_parameters", |
| 2699 | reason: "value is required", |
| 2700 | } |
| 2701 | } |
| 2702 | |
| 2703 | if v, ok := interface{}(m.GetCurrentParameters()).(interface{ ValidateFields(...string) error }); ok { |
| 2704 | if err := v.ValidateFields(subs...); err != nil { |
| 2705 | return MACStateValidationError{ |
| 2706 | field: "current_parameters", |
| 2707 | reason: "embedded message failed validation", |
| 2708 | cause: err, |
| 2709 | } |
| 2710 | } |
| 2711 | } |
| 2712 | |
| 2713 | case "desired_parameters": |
| 2714 | |
| 2715 | if m.GetDesiredParameters() == nil { |
| 2716 | return MACStateValidationError{ |
| 2717 | field: "desired_parameters", |
| 2718 | reason: "value is required", |
| 2719 | } |
| 2720 | } |
| 2721 | |
| 2722 | if v, ok := interface{}(m.GetDesiredParameters()).(interface{ ValidateFields(...string) error }); ok { |
| 2723 | if err := v.ValidateFields(subs...); err != nil { |
| 2724 | return MACStateValidationError{ |
| 2725 | field: "desired_parameters", |
| 2726 | reason: "embedded message failed validation", |
| 2727 | cause: err, |
| 2728 | } |
| 2729 | } |
| 2730 | } |
| 2731 | |
| 2732 | case "device_class": |
| 2733 | |
| 2734 | if _, ok := Class_name[int32(m.GetDeviceClass())]; !ok { |
| 2735 | return MACStateValidationError{ |
| 2736 | field: "device_class", |
| 2737 | reason: "value must be one of the defined enum values", |
| 2738 | } |
| 2739 | } |
nothing calls this directly
no test coverage detected