validator

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v1.2.0

type Config struct {
	PasswordLenMin        uint
	PasswordLenMax        uint
	EmailLenMax           uint
	PostContentsLenMin    uint
	PostContentsLenMax    uint
	PostTitleLenMin       uint
	PostTitleLenMax       uint
	ReactionMessageLenMin uint
	ReactionMessageLenMax uint
	UserDisplayNameLenMin uint
	UserDisplayNameLenMax uint
}

Config represents the validator configuration

type Validator

type Validator interface {
	// Email returns an error if the given email address is invalid,
	// otherwise returns nil
	Email(v string) error

	// Password returns an error if the given password is invalid,
	// otherwise returns nil
	Password(v string) error

	// PostContents returns an error if the given post contents are invalid,
	// otherwise returns nil
	PostContents(v string) error

	// PostTitle returns an error if the given post title is invalid,
	// otherwise returns nil
	PostTitle(v string) error

	// ReactionMessage returns an error if the given reaction message is
	// invalid, otherwise returns nil
	ReactionMessage(v string) error

	// UserDisplayName returns an error if the given user display name is
	// invalid, otherwise returns nil
	UserDisplayName(v string) error
}

Validator represents a validator interface

func NewValidator

func NewValidator(productionModeEnabled bool, conf Config) (Validator, error)

NewValidator creates a new validator instance

Jump to

Keyboard shortcuts

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