From f154c55862f395e56a42a8758f75d67435ab9ae7 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Tue, 1 May 2018 18:26:50 +0000 Subject: [PATCH] Catch spam bots on my contact form --- internal/forms/contact.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/forms/contact.go b/internal/forms/contact.go index 2cebbed..f2d543a 100644 --- a/internal/forms/contact.go +++ b/internal/forms/contact.go @@ -38,5 +38,11 @@ func (c Contact) Validate() error { if len(c.Message) == 0 { return errors.New("message is required") } + + // Spam bot traps. + if c.Trap1 != "" || c.Trap2 != "http://" { + return errors.New("message can't be delivered") + } + return nil }