From 8154a50351587b45c087dcd522525f7dd858bc54 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Mon, 8 Apr 2024 15:56:12 +0200 Subject: [PATCH] [core] Enforce field validation on config Signed-off-by: Knut Ahlers --- action_script.go | 12 ++++++++---- internal/actors/clip/actor.go | 2 ++ internal/actors/commercial/actor.go | 1 + internal/actors/counter/actor.go | 1 + internal/actors/delay/actor.go | 10 +++++++++- internal/actors/eventmod/actor.go | 1 + internal/actors/filesay/actor.go | 1 + internal/actors/linkdetector/actor.go | 11 ++++++++++- internal/actors/linkprotect/actor.go | 7 +++++++ internal/actors/log/actor.go | 1 + internal/actors/modchannel/actor.go | 1 + internal/actors/nuke/actor.go | 1 + internal/actors/punish/actor.go | 2 ++ internal/actors/quotedb/actor.go | 1 + internal/actors/raw/actor.go | 1 + internal/actors/respond/actor.go | 1 + internal/actors/shield/actor.go | 1 + internal/actors/shoutout/actor.go | 1 + internal/actors/stopexec/actor.go | 1 + internal/actors/timeout/actor.go | 1 + internal/actors/variables/actor.go | 1 + internal/actors/vip/vip.go | 1 + internal/actors/whisper/actor.go | 1 + internal/apimodules/customevent/actor.go | 1 + internal/apimodules/raffle/actor.go | 1 + 25 files changed, 57 insertions(+), 6 deletions(-) diff --git a/action_script.go b/action_script.go index e22928d..3e60c9f 100644 --- a/action_script.go +++ b/action_script.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "encoding/json" + "fmt" "os" "os/exec" @@ -132,12 +133,15 @@ func (ActorScript) Name() string { return "script" } // Validate implements actor interface func (ActorScript) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldcollection.FieldCollection) (err error) { - cmd, err := attrs.StringSlice("command") - if err != nil || len(cmd) == 0 { - return errors.New("command must be slice of strings with length > 0") + if err = attrs.ValidateSchema( + fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "command", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeStringSlice}), + fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "skip_cooldown_on_error", Type: fieldcollection.SchemaFieldTypeBool}), + fieldcollection.MustHaveNoUnknowFields, + ); err != nil { + return fmt.Errorf("validating attributes: %w", err) } - for i, el := range cmd { + for i, el := range attrs.MustStringSlice("command", nil) { if err = tplValidator(el); err != nil { return errors.Wrapf(err, "validating cmd template (element %d)", i) } diff --git a/internal/actors/clip/actor.go b/internal/actors/clip/actor.go index 9f86a4d..8b5879d 100644 --- a/internal/actors/clip/actor.go +++ b/internal/actors/clip/actor.go @@ -113,6 +113,8 @@ func (actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldco if err = attrs.ValidateSchema( fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "channel", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "creator", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "add_delay", Type: fieldcollection.SchemaFieldTypeBool}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "channel", "creator"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/commercial/actor.go b/internal/actors/commercial/actor.go index ad6f797..f35e2bc 100644 --- a/internal/actors/commercial/actor.go +++ b/internal/actors/commercial/actor.go @@ -81,6 +81,7 @@ func (actor) Name() string { return actorName } func (actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldcollection.FieldCollection) (err error) { if err = attrs.ValidateSchema( fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "duration", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "duration"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/counter/actor.go b/internal/actors/counter/actor.go index 367650e..c9e624a 100644 --- a/internal/actors/counter/actor.go +++ b/internal/actors/counter/actor.go @@ -263,6 +263,7 @@ func (actorCounter) Validate(tplValidator plugins.TemplateValidatorFunc, attrs * fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "counter", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "counter_step", Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "counter_set", Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "counter", "counter_step", "counter_set"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/delay/actor.go b/internal/actors/delay/actor.go index 5fdea17..e8e53d4 100644 --- a/internal/actors/delay/actor.go +++ b/internal/actors/delay/actor.go @@ -2,6 +2,7 @@ package delay import ( + "fmt" "math/rand" "time" @@ -72,6 +73,13 @@ func (actor) Execute(_ *irc.Client, _ *irc.Message, _ *plugins.Rule, _ *fieldcol func (actor) IsAsync() bool { return false } func (actor) Name() string { return actorName } -func (actor) Validate(plugins.TemplateValidatorFunc, *fieldcollection.FieldCollection) (err error) { +func (actor) Validate(_ plugins.TemplateValidatorFunc, attrs *fieldcollection.FieldCollection) (err error) { + if err = attrs.ValidateSchema( + fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "delay", Type: fieldcollection.SchemaFieldTypeDuration}), + fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "jitter", Type: fieldcollection.SchemaFieldTypeDuration}), + fieldcollection.MustHaveNoUnknowFields, + ); err != nil { + return fmt.Errorf("validating attributes: %w", err) + } return nil } diff --git a/internal/actors/eventmod/actor.go b/internal/actors/eventmod/actor.go index ddea0c3..edb5ecf 100644 --- a/internal/actors/eventmod/actor.go +++ b/internal/actors/eventmod/actor.go @@ -75,6 +75,7 @@ func (actor) Name() string { return actorName } func (actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldcollection.FieldCollection) (err error) { if err = attrs.ValidateSchema( fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "fields", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "fields"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/filesay/actor.go b/internal/actors/filesay/actor.go index 2b456b9..ebb28b4 100644 --- a/internal/actors/filesay/actor.go +++ b/internal/actors/filesay/actor.go @@ -120,6 +120,7 @@ func (actor) Name() string { return actorName } func (actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldcollection.FieldCollection) (err error) { if err = attrs.ValidateSchema( fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "source", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "source"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/linkdetector/actor.go b/internal/actors/linkdetector/actor.go index 150e167..6722cb1 100644 --- a/internal/actors/linkdetector/actor.go +++ b/internal/actors/linkdetector/actor.go @@ -3,6 +3,8 @@ package linkdetector import ( + "fmt" + "gopkg.in/irc.v4" "github.com/Luzifer/go_helpers/v2/fieldcollection" @@ -64,6 +66,13 @@ func (Actor) IsAsync() bool { return false } func (Actor) Name() string { return actorName } // Validate implements the actor interface -func (Actor) Validate(plugins.TemplateValidatorFunc, *fieldcollection.FieldCollection) error { +func (Actor) Validate(_ plugins.TemplateValidatorFunc, attrs *fieldcollection.FieldCollection) (err error) { + if err = attrs.ValidateSchema( + fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "heuristic", Type: fieldcollection.SchemaFieldTypeBool}), + fieldcollection.MustHaveNoUnknowFields, + ); err != nil { + return fmt.Errorf("validating attributes: %w", err) + } + return nil } diff --git a/internal/actors/linkprotect/actor.go b/internal/actors/linkprotect/actor.go index 39931ec..54984d5 100644 --- a/internal/actors/linkprotect/actor.go +++ b/internal/actors/linkprotect/actor.go @@ -223,6 +223,13 @@ func (actor) Validate(_ plugins.TemplateValidatorFunc, attrs *fieldcollection.Fi if err = attrs.ValidateSchema( fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "action", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "reason", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "allowed_links", Type: fieldcollection.SchemaFieldTypeStringSlice}), + fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "disallowed_links", Type: fieldcollection.SchemaFieldTypeStringSlice}), + fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "allowed_clip_channels", Type: fieldcollection.SchemaFieldTypeStringSlice}), + fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "disallowed_clip_channels", Type: fieldcollection.SchemaFieldTypeStringSlice}), + fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "stop_on_action", Type: fieldcollection.SchemaFieldTypeBool}), + fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "stop_on_no_action", Type: fieldcollection.SchemaFieldTypeBool}), + fieldcollection.MustHaveNoUnknowFields, func(attrs, _ *fieldcollection.FieldCollection) error { if len(attrs.MustStringSlice("allowed_links", helpers.Ptr([]string{})))+ len(attrs.MustStringSlice("disallowed_links", helpers.Ptr([]string{})))+ diff --git a/internal/actors/log/actor.go b/internal/actors/log/actor.go index 45939c5..44562b6 100644 --- a/internal/actors/log/actor.go +++ b/internal/actors/log/actor.go @@ -65,6 +65,7 @@ func (actor) Name() string { return "log" } func (actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldcollection.FieldCollection) (err error) { if err = attrs.ValidateSchema( fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "message", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "message"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/modchannel/actor.go b/internal/actors/modchannel/actor.go index 8d0304f..0e837b0 100644 --- a/internal/actors/modchannel/actor.go +++ b/internal/actors/modchannel/actor.go @@ -125,6 +125,7 @@ func (actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldco fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "channel", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "game", Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "title", Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "channel", "game", "title"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/nuke/actor.go b/internal/actors/nuke/actor.go index 397a484..fe869f6 100644 --- a/internal/actors/nuke/actor.go +++ b/internal/actors/nuke/actor.go @@ -239,6 +239,7 @@ func (actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldco fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "match", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "action", Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "scan", Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "scan", "action", "match"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/punish/actor.go b/internal/actors/punish/actor.go index 9bd1f21..08cd003 100644 --- a/internal/actors/punish/actor.go +++ b/internal/actors/punish/actor.go @@ -233,6 +233,7 @@ func (actorPunish) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *f fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "cooldown", Type: fieldcollection.SchemaFieldTypeDuration}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "reason", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "uuid", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "user"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) @@ -266,6 +267,7 @@ func (actorResetPunish) Validate(tplValidator plugins.TemplateValidatorFunc, att if err = attrs.ValidateSchema( fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "user", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "uuid", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "user"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/quotedb/actor.go b/internal/actors/quotedb/actor.go index 2adc75c..1a0996d 100644 --- a/internal/actors/quotedb/actor.go +++ b/internal/actors/quotedb/actor.go @@ -198,6 +198,7 @@ func (actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldco fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "quote", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "index", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "format", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "index", "quote", "format"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/raw/actor.go b/internal/actors/raw/actor.go index d6e3b74..a39ff85 100644 --- a/internal/actors/raw/actor.go +++ b/internal/actors/raw/actor.go @@ -72,6 +72,7 @@ func (actor) Name() string { return actorName } func (actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldcollection.FieldCollection) (err error) { if err = attrs.ValidateSchema( fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "message", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "message"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/respond/actor.go b/internal/actors/respond/actor.go index de381ea..c0d011a 100644 --- a/internal/actors/respond/actor.go +++ b/internal/actors/respond/actor.go @@ -151,6 +151,7 @@ func (actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldco fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "fallback", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "as_reply", Type: fieldcollection.SchemaFieldTypeBool}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "to_channel", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "message", "fallback"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/shield/actor.go b/internal/actors/shield/actor.go index b6eb0a3..286c30a 100644 --- a/internal/actors/shield/actor.go +++ b/internal/actors/shield/actor.go @@ -65,6 +65,7 @@ func (actor) Name() string { return actorName } func (actor) Validate(_ plugins.TemplateValidatorFunc, attrs *fieldcollection.FieldCollection) (err error) { if err = attrs.ValidateSchema( fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "enable", Type: fieldcollection.SchemaFieldTypeBool}), + fieldcollection.MustHaveNoUnknowFields, ); err != nil { return fmt.Errorf("validating attributes: %w", err) } diff --git a/internal/actors/shoutout/actor.go b/internal/actors/shoutout/actor.go index c3d2827..4f027ff 100644 --- a/internal/actors/shoutout/actor.go +++ b/internal/actors/shoutout/actor.go @@ -80,6 +80,7 @@ func (actor) Name() string { return actorName } func (actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldcollection.FieldCollection) (err error) { if err = attrs.ValidateSchema( fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "user", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "user"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/stopexec/actor.go b/internal/actors/stopexec/actor.go index d692b51..b68c495 100644 --- a/internal/actors/stopexec/actor.go +++ b/internal/actors/stopexec/actor.go @@ -65,6 +65,7 @@ func (actor) Name() string { return actorName } func (actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldcollection.FieldCollection) (err error) { if err = attrs.ValidateSchema( fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "when", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "when"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/timeout/actor.go b/internal/actors/timeout/actor.go index e84e18d..e69890d 100644 --- a/internal/actors/timeout/actor.go +++ b/internal/actors/timeout/actor.go @@ -93,6 +93,7 @@ func (actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldco if err = attrs.ValidateSchema( fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "duration", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeDuration}), fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "reason", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "reason"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/variables/actor.go b/internal/actors/variables/actor.go index a188c93..759762a 100644 --- a/internal/actors/variables/actor.go +++ b/internal/actors/variables/actor.go @@ -178,6 +178,7 @@ func (actorSetVariable) Validate(tplValidator plugins.TemplateValidatorFunc, att fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "variable", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "clear", Type: fieldcollection.SchemaFieldTypeBool}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "set", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "set", "variable"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/vip/vip.go b/internal/actors/vip/vip.go index 17e64e4..db473c4 100644 --- a/internal/actors/vip/vip.go +++ b/internal/actors/vip/vip.go @@ -103,6 +103,7 @@ func (actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldco if err = attrs.ValidateSchema( fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "channel", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "user", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "channel", "user"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/actors/whisper/actor.go b/internal/actors/whisper/actor.go index 3f00c87..4f26b9b 100644 --- a/internal/actors/whisper/actor.go +++ b/internal/actors/whisper/actor.go @@ -84,6 +84,7 @@ func (actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldco if err = attrs.ValidateSchema( fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "message", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "to", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "message", "to"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/apimodules/customevent/actor.go b/internal/apimodules/customevent/actor.go index a09b55b..f27b9d0 100644 --- a/internal/apimodules/customevent/actor.go +++ b/internal/apimodules/customevent/actor.go @@ -42,6 +42,7 @@ func (actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *fieldco if err = attrs.ValidateSchema( fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "fields", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), fieldcollection.CanHaveField(fieldcollection.SchemaField{Name: "schedule_in", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, helpers.SchemaValidateTemplateField(tplValidator, "fields", "schedule_in"), ); err != nil { return fmt.Errorf("validating attributes: %w", err) diff --git a/internal/apimodules/raffle/actor.go b/internal/apimodules/raffle/actor.go index 3bd5af4..42a86b8 100644 --- a/internal/apimodules/raffle/actor.go +++ b/internal/apimodules/raffle/actor.go @@ -75,6 +75,7 @@ func (enterRaffleActor) Name() string { return "enter-raffle" } func (enterRaffleActor) Validate(_ plugins.TemplateValidatorFunc, attrs *fieldcollection.FieldCollection) (err error) { if err = attrs.ValidateSchema( fieldcollection.MustHaveField(fieldcollection.SchemaField{Name: "keyword", NonEmpty: true, Type: fieldcollection.SchemaFieldTypeString}), + fieldcollection.MustHaveNoUnknowFields, ); err != nil { return fmt.Errorf("validating attributes: %w", err) }