validator

package
v0.9.13 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NilValidatorError = errors.New("validator cannot be nil")
)

Functions

This section is empty.

Types

type DefaultValidator

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

DefaultValidator struct

func NewDefaultValidator

func NewDefaultValidator(mode *commonflag.ModeFlag) *DefaultValidator

NewDefaultValidator creates a new default validator

func (*DefaultValidator) CheckValidations

func (d *DefaultValidator) CheckValidations(
	structFieldsValidations *commonvalidatorfields.StructFieldsValidations,
	code codes.Code,
) error

CheckValidations checks if there are any validations

func (*DefaultValidator) ValidateBirthdate

func (d *DefaultValidator) ValidateBirthdate(
	birthdateField string,
	birthdate *timestamppb.Timestamp,
	structFieldsValidations *commonvalidatorfields.StructFieldsValidations,
)

ValidateBirthdate validates the birthdate field

func (*DefaultValidator) ValidateEmail

func (d *DefaultValidator) ValidateEmail(
	emailField string,
	email string,
	structFieldsValidations *commonvalidatorfields.StructFieldsValidations,
)

ValidateEmail validates the email address field

func (*DefaultValidator) ValidateNilFields added in v0.9.0

func (d *DefaultValidator) ValidateNilFields(
	request interface{},
	structFieldsToValidate *commonvalidatorfields.StructFieldsToValidate,
) (*commonvalidatorfields.StructFieldsValidations, error)

ValidateNilFields validates the nil fields

type Validator

type Validator interface {
	ValidateEmail(
		emailField string,
		email string,
		structFieldsValidations *commonvalidatorfields.StructFieldsValidations,
	)
	ValidateBirthdate(
		birthdateField string,
		birthdate *timestamppb.Timestamp,
		structFieldsValidations *commonvalidatorfields.StructFieldsValidations,
	)
	ValidateNilFields(request interface{}, structFieldsToValidate *commonvalidatorfields.StructFieldsToValidate) (
		*commonvalidatorfields.StructFieldsValidations,
		error,
	)
	CheckValidations(structFieldsValidations *commonvalidatorfields.StructFieldsValidations, code codes.Code) error
}

Validator interface

Jump to

Keyboard shortcuts

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