validator

package module
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2023 License: LGPL-3.0 Imports: 10 Imported by: 3

README

validator

Library that validates different things:

  • A/CNAME/MX lookups
  • Domain names
  • Emails
  • etc

Check go doc for examples

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Enforce added in v1.0.1

type Enforce struct {
	// Email enforces email check and rejects empty emails
	Email bool
	// Domain enforces domain check and rejects empty domains
	Domain bool
	// SMTP enforces SMTP check (email actually exists on mail server) and rejects non-existing emails
	SMTP bool
	// SPF enforces SPF record check (sender allowed to use that email and send emails) and rejects unathorized emails
	SPF bool
	// MX enforces MX records check on email's mail server
	MX bool
}

Enforce checks

type Logger

type Logger interface {
	Info(string, ...interface{})
	Error(string, ...interface{})
}

type V

type V struct {
	// contains filtered or unexported fields
}

V is a validator implementation

func New

func New(spamlist []string, enforce Enforce, smtpFrom string, log Logger) *V

New Validator, accepts spamlist with wildcards

func (*V) A

func (v *V) A(host string) bool

A checks if host has at least one A record

func (*V) CNAME

func (v *V) CNAME(host string) bool

CNAME checks if host has at least one CNAME record

func (*V) Domain

func (v *V) Domain(domain string) bool

Domain checks if domain is valid

func (*V) DomainString

func (v *V) DomainString(domain string) bool

DomainString checks if domain string / value is valid using string checks like length and regexp

func (*V) Email

func (v *V) Email(email string, optionalSenderIP ...net.IP) bool

Email checks if email is valid

func (*V) GetBase

func (v *V) GetBase(domain string) string

GetBase returns base domain/host of the provided domain

func (*V) MX

func (v *V) MX(host string) bool

MX checks if host has at least one MX record

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL