validators

package
v0.0.0-...-e0091a7 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VERIFICATION_FIELD_PIN_MIN_LENGTH = 4
	VERIFICATION_FIELD_PIN_MAX_LENGTH = 8

	VERIFICATION_FIELD_MAX_ID_LENGTH = 50
)

Variables

View Source
var (
	DefaultUserSortField = data.SortFieldEmail
	DefaultUserSortOrder = data.SortOrderASC
	AllowedUserSorts     = []data.SortField{data.SortFieldEmail, data.SortFieldIsActive}
)

Functions

This section is empty.

Types

type DisbursementInstructionsValidator

type DisbursementInstructionsValidator struct {
	*Validator
	// contains filtered or unexported fields
}

func NewDisbursementInstructionsValidator

func NewDisbursementInstructionsValidator(verificationField data.VerificationField) *DisbursementInstructionsValidator

func (*DisbursementInstructionsValidator) SanitizeInstruction

func (*DisbursementInstructionsValidator) ValidateInstruction

func (iv *DisbursementInstructionsValidator) ValidateInstruction(instruction *data.DisbursementInstruction, lineNumber int)

type DisbursementQueryValidator

type DisbursementQueryValidator struct {
	QueryValidator
}

func NewDisbursementQueryValidator

func NewDisbursementQueryValidator() *DisbursementQueryValidator

NewDisbursementQueryValidator creates a new DisbursementQueryValidator with the provided configuration.

func (*DisbursementQueryValidator) ValidateAndGetDisbursementFilters

func (qv *DisbursementQueryValidator) ValidateAndGetDisbursementFilters(filters map[data.FilterKey]interface{}) map[data.FilterKey]interface{}

ValidateAndGetDisbursementFilters validates the filters and returns a map of valid filters.

type DisbursementRequestValidator

type DisbursementRequestValidator struct {
	*Validator
	// contains filtered or unexported fields
}

func NewDisbursementRequestValidator

func NewDisbursementRequestValidator(verificationField data.VerificationField) *DisbursementRequestValidator

func (*DisbursementRequestValidator) ValidateAndGetVerificationType

func (dv *DisbursementRequestValidator) ValidateAndGetVerificationType() data.VerificationField

ValidateAndGetVerificationType validates if the verification type field is a valid value.

type GoogleReCAPTCHAValidator

type GoogleReCAPTCHAValidator struct {
	SiteSecretKey  string
	VerifyTokenURL string
	BaseURL        string
	HTTPClient     HTTPClient
}

func NewGoogleReCAPTCHAValidator

func NewGoogleReCAPTCHAValidator(siteSecretKey string, httpClient HTTPClient) *GoogleReCAPTCHAValidator

func (*GoogleReCAPTCHAValidator) IsTokenValid

func (v *GoogleReCAPTCHAValidator) IsTokenValid(ctx context.Context, token string) (bool, error)

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type PatchWalletRequest

type PatchWalletRequest struct {
	Enabled *bool `json:"enabled"`
}

type PaymentQueryValidator

type PaymentQueryValidator struct {
	QueryValidator
}

func NewPaymentQueryValidator

func NewPaymentQueryValidator() *PaymentQueryValidator

NewPaymentQueryValidator creates a new PaymentQueryValidator with the provided configuration.

func (*PaymentQueryValidator) ValidateAndGetPaymentFilters

func (qv *PaymentQueryValidator) ValidateAndGetPaymentFilters(filters map[data.FilterKey]interface{}) map[data.FilterKey]interface{}

ValidateAndGetPaymentFilters validates the filters and returns a map of valid filters.

type QueryValidator

type QueryValidator struct {
	*Validator
	DefaultSortField  data.SortField
	DefaultSortOrder  data.SortOrder
	AllowedSortFields []data.SortField
	AllowedFilters    []data.FilterKey
}

func (*QueryValidator) ParseParametersFromRequest

func (qv *QueryValidator) ParseParametersFromRequest(r *http.Request) *data.QueryParams

ParseParametersFromRequest parses query parameters from the request and returns a QueryParams struct.

func (*QueryValidator) ValidateAndGetTimeParams

func (qv *QueryValidator) ValidateAndGetTimeParams(param string, value interface{}) time.Time

ValidateAndGetTimeParams validates the query parameter and returns the value as a time.Time.

type ReCAPTCHAValidator

type ReCAPTCHAValidator interface {
	IsTokenValid(ctx context.Context, token string) (bool, error)
}

type ReCAPTCHAValidatorMock

type ReCAPTCHAValidatorMock struct {
	mock.Mock
}

func (*ReCAPTCHAValidatorMock) IsTokenValid

func (v *ReCAPTCHAValidatorMock) IsTokenValid(ctx context.Context, token string) (bool, error)

type ReceiverQueryValidator

type ReceiverQueryValidator struct {
	QueryValidator
}

func NewReceiverQueryValidator

func NewReceiverQueryValidator() *ReceiverQueryValidator

NewReceiverQueryValidator creates a new ReceiverQueryValidator with the provided configuration.

func (*ReceiverQueryValidator) ValidateAndGetReceiverFilters

func (qv *ReceiverQueryValidator) ValidateAndGetReceiverFilters(filters map[data.FilterKey]interface{}) map[data.FilterKey]interface{}

ValidateAndGetReceiverFilters validates the filters and returns a map of valid filters.

type ReceiverRegistrationValidator

type ReceiverRegistrationValidator struct {
	*Validator
}

func NewReceiverRegistrationValidator

func NewReceiverRegistrationValidator() *ReceiverRegistrationValidator

NewReceiverRegistrationValidator creates a new ReceiverRegistrationValidator with the provided configuration.

func (*ReceiverRegistrationValidator) ValidateReceiver

func (rv *ReceiverRegistrationValidator) ValidateReceiver(receiverInfo *data.ReceiverRegistrationRequest)

ValidateReceiver validates if the infos present in the ReceiverRegistrationRequest are valids.

type UpdateReceiverRequest

type UpdateReceiverRequest struct {
	DateOfBirth string `json:"date_of_birth"`
	Pin         string `json:"pin"`
	NationalID  string `json:"national_id"`
	Email       string `json:"email"`
	ExternalID  string `json:"external_id"`
}

type UpdateReceiverValidator

type UpdateReceiverValidator struct {
	*Validator
}

func NewUpdateReceiverValidator

func NewUpdateReceiverValidator() *UpdateReceiverValidator

NewReceiverRegistrationValidator creates a new ReceiverRegistrationValidator with the provided configuration.

func (*UpdateReceiverValidator) ValidateReceiver

func (ur *UpdateReceiverValidator) ValidateReceiver(updateReceiverRequest *UpdateReceiverRequest)

ValidateReceiver validates if the infos present in the ReceiverRegistrationRequest are valids.

type UserQueryValidator

type UserQueryValidator struct {
	QueryValidator
}

func NewUserQueryValidator

func NewUserQueryValidator() *UserQueryValidator

NewUserQueryValidator creates a new UserQueryValidator with the provided configuration.

type Validator

type Validator struct {
	Errors map[string]interface{}
}

func NewValidator

func NewValidator() *Validator

func (*Validator) Check

func (v *Validator) Check(ok bool, key, message string)

func (*Validator) CheckError

func (v *Validator) CheckError(err error, key, message string)

CheckError is a convenience method for checking if an error is nil

func (*Validator) HasErrors

func (v *Validator) HasErrors() bool

type WalletRequest

type WalletRequest struct {
	Name              string   `json:"name"`
	Homepage          string   `json:"homepage"`
	DeepLinkSchema    string   `json:"deep_link_schema"`
	SEP10ClientDomain string   `json:"sep_10_client_domain"`
	AssetsIDs         []string `json:"assets_ids"`
}

type WalletValidator

type WalletValidator struct {
	*Validator
}

func NewWalletValidator

func NewWalletValidator() *WalletValidator

func (*WalletValidator) ValidateCreateWalletRequest

func (wv *WalletValidator) ValidateCreateWalletRequest(ctx context.Context, reqBody *WalletRequest) *WalletRequest

func (*WalletValidator) ValidatePatchWalletRequest

func (wv *WalletValidator) ValidatePatchWalletRequest(reqBody *PatchWalletRequest)

Jump to

Keyboard shortcuts

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