exception

package
v0.0.0-...-d941976 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequiredTag         = "required"
	EqFieldTag          = "eqfield"
	MinTag              = "min"
	MaxTag              = "max"
	Base64Tag           = "base64"
	EmailTag            = "email"
	HiraganaTag         = "hiragana"
	PasswordTag         = "password"
	UniqueTag           = "unique"
	LessThanTag         = "lt"
	LessThanEqualTag    = "lte"
	GreaterThanTag      = "gt"
	GreaterThanEqualTag = "gte"
	OneOfTag            = "oneof"
)

バリデーションタグ

View Source
const (
	RequiredMessage         = "is required"
	EqFieldMessage          = "does not match %s"
	MinMessage              = "must be at least %s characters"
	MaxMessage              = "must be at %s or less characters"
	Base64Message           = "should be in base64 format"
	EmailMessage            = "should be in email format"
	HiraganaMessage         = "should be in hiragana format"
	PasswordMessage         = "should be in password format"
	UniqueMessage           = "must be unique"
	LessThanMessage         = "must be at less than %s"
	LessThanEuqalMessage    = "must be at less than or equal to %s"
	GreaterThanMessage      = "must be at greater than %s"
	GreaterThanEqualMessage = "must be at greater than or equal to %s"
	OneOfMessage            = "must be one of %s"
)

バリデーションメッセージ

View Source
const (
	CustomUniqueMessage        = "already exists"
	UnableConvertBase64Massage = "cannot be converted to base64"
)

カスタムバリデーションメッセージ

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomError

type CustomError struct {
	ErrorCode        ErrorCode
	Value            error
	ValidationErrors []*ValidationError
}

CustomError - エラーコードを含めた構造体

func (CustomError) Code

func (ce CustomError) Code() ErrorCode

Code - エラーコードを返す

func (CustomError) Error

func (ce CustomError) Error() string

Error - エラー内容を返す

func (CustomError) Validations

func (ce CustomError) Validations() []*ValidationError

Validations - バリデーションエラーの詳細を返す

type ErrorCode

type ErrorCode uint

ErrorCode - システムエラーの種類

const (
	// Unknown - 不明なエラー
	Unknown ErrorCode = iota
	// ErrorInDatastore - データストアでのエラー
	ErrorInDatastore
	// ErrorInStorage - ストレージでのエラー
	ErrorInStorage
	// ErrorInOtherAPI - 他のAPIでのエラー
	ErrorInOtherAPI
	// InvalidDomainValidation - ドメイン層でのバリデーションエラー
	InvalidDomainValidation
	// InvalidRequestValidation - リクエスト値のバリデーションエラ
	InvalidRequestValidation
	// UnableConvertBase64 - Byte64型への変換エラー
	UnableConvertBase64
	// Unauthorized - 認証エラー
	Unauthorized
	// Expired - セッションが有効期限切れ
	Expired
	// Forbidden - 権限エラー
	Forbidden
	// NotFound - 取得エラー
	NotFound
	// NotExistsInDatastore - データストアに対象のレコードが存在しない
	NotExistsInDatastore
	// NotExistsInStorage - ストレージに対象のファイルが存在しない
	NotExistsInStorage
	// Conflict - 既存レコード,ファイルとの競合
	Conflict
)

func (ErrorCode) New

func (ec ErrorCode) New(err error, ves ...*ValidationError) error

New - 指定したErrorCodeを持つCustomErrorを返す

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError - バリデーションエラー用構造体

Jump to

Keyboard shortcuts

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