2026-06-20 20:48:09 +02:00
|
|
|
//go:build linux || freebsd
|
|
|
|
|
|
|
|
|
|
// Minimal example showing how to use the contactform package
|
|
|
|
|
// standalone (without the HTTP server).
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"os"
|
|
|
|
|
|
2026-07-26 20:29:01 +02:00
|
|
|
"sourcedock.dev/petrbalvin/nuntius/pkg/contactform"
|
2026-06-20 20:48:09 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
req := &contactform.Request{
|
|
|
|
|
Name: "Jane Doe",
|
|
|
|
|
Email: "jane@example.com",
|
|
|
|
|
Service: "architecture",
|
|
|
|
|
Message: "Hi, I'd like to discuss a possible engagement.",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if errs := contactform.Validate(req, "contact"); len(errs) > 0 {
|
|
|
|
|
fmt.Fprintln(os.Stderr, "validation failed:")
|
|
|
|
|
for _, e := range errs {
|
|
|
|
|
fmt.Fprintf(os.Stderr, " - %s: %s\n", e.Field, e.Message)
|
|
|
|
|
}
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fmt.Println("Request is valid:")
|
|
|
|
|
fmt.Printf(" name: %s\n", req.Name)
|
|
|
|
|
fmt.Printf(" email: %s\n", req.Email)
|
|
|
|
|
fmt.Printf(" service: %s\n", req.Service)
|
|
|
|
|
fmt.Printf(" message: %s\n", req.Message)
|
|
|
|
|
}
|