func (a *AuditProfileRule) Validate() error {

	if a.Type < DeleteAllRuleType || a.Type > PrependSyscallRuleType {
		return elemental.NewError("Validation Error", "Invalid rule type", "elemental", http.StatusUnprocessableEntity)
	}

	switch a.Type {
	case AppendSyscallRuleType, PrependSyscallRuleType:
		if a.Syscalls == nil {
			return elemental.NewError("Validation Error", "Nil syscall rule not allowed", "elemental", http.StatusUnprocessableEntity)
		}
		return a.Syscalls.Validate()
	case FileWatchRuleType:
		if a.Files == nil || a.Syscalls != nil {
			return elemental.NewError("Validation Error", "Nil file watch rule not allowed", "elemental", http.StatusUnprocessableEntity)
		}
		return a.Files.Validate()
	case DeleteAllRuleType:
		if a.Files != nil || a.Syscalls != nil {
			return elemental.NewError("Validation Error", "Delete rule must not have syscall or file", "elemental", http.StatusUnprocessableEntity)
		}
	default:
		return elemental.NewError("Validation Error", "Invalid rule type", "elemental", http.StatusUnprocessableEntity)
	}

	return nil
}
// Validate validates an audit rule
Validate validates an audit rule
// Validate validates an audit rule
func (a *AuditProfileRule) Validate() error {
	if a.Type < DeleteAllRuleType || a.Type > PrependSyscallRuleType {
		return elemental.NewError("Validation Error", "Invalid rule type", "elemental", http.StatusUnprocessableEntity)
	}
	switch a.Type {
	case AppendSyscallRuleType, PrependSyscallRuleType:
		if a.Syscalls == nil {
			return elemental.NewError("Validation Error", "Nil syscall rule not allowed", "elemental", http.StatusUnprocessableEntity)
		}
		return a.Syscalls.Validate()
	case FileWatchRuleType:
		if a.Files == nil || a.Syscalls != nil {
			return elemental.NewError("Validation Error", "Nil file watch rule not allowed", "elemental", http.StatusUnprocessableEntity)
		}
		return a.Files.Validate()
	case DeleteAllRuleType:
		if a.Files != nil || a.Syscalls != nil {
			return elemental.NewError("Validation Error", "Delete rule must not have syscall or file", "elemental", http.StatusUnprocessableEntity)
		}
	default:
		return elemental.NewError("Validation Error", "Invalid rule type", "elemental", http.StatusUnprocessableEntity)
	}
	return nil
}
func ( a * AuditProfileRule ) Validate ( ) error { if a . Type < DeleteAllRuleType || a . Type > PrependSyscallRuleType { return elemental . NewError ( " " , " " , " " , http . StatusUnprocessableEntity ) } switch a . Type { case AppendSyscallRuleType , PrependSyscallRuleType : if a . Syscalls == nil { return elemental . NewError ( " " , " " , " " , http . StatusUnprocessableEntity ) } return a . Syscalls . Validate ( ) case FileWatchRuleType : if a . Files == nil || a . Syscalls != nil { return elemental . NewError ( " " , " " , " " , http . StatusUnprocessableEntity ) } return a . Files . Validate ( ) case DeleteAllRuleType : if a . Files != nil || a . Syscalls != nil { return elemental . NewError ( " " , " " , " " , http . StatusUnprocessableEntity ) } default : return elemental . NewError ( " " , " " , " " , http . StatusUnprocessableEntity ) } return nil }
Validate validates an audit rule
Validate validates an audit rule