helpers

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: BSD-2-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDocumentIsRevoked is returned when a document is revoked
	ErrDocumentIsRevoked = NewError("DOCUMENT_IS_REVOKED")
	// ErrNoTransactionID is returned when transactionID is not present
	ErrNoTransactionID = NewError("NO_TRANSACTION_ID")

	// ErrNoDocumentFound is returned when no document is found
	ErrNoDocumentFound = NewError("NO_DOCUMENT_FOUND")

	// ErrDocumentAlreadyExists is returned when a document already exists
	ErrDocumentAlreadyExists = NewError("DOCUMENT_ALREADY_EXISTS")

	// ErrNoDocumentData is returned when no document_data is found
	ErrNoDocumentData = NewError("NO_DOCUMENT_DATA")

	// ErrNoIdentityFound is returned when no identity is found
	ErrNoIdentityFound = NewError("NO_IDENTITY_FOUND")

	// ErrDuplicateKey is returned when a duplicate key is found
	ErrDuplicateKey = NewError("DUPLICATE_KEY")

	// ErrNoRevocationID is returned when no revocation_id is found
	ErrNoRevocationID = NewError("NO_REVOCATION_ID")

	// ErrPrivateKeyMissing error for empty private key
	ErrPrivateKeyMissing = NewError("ERR_PRIVATE_KEY_MISSING")

	// ErrNoKnownVCT error for no known vct
	ErrNoKnownVCT = NewError("ERR_NO_KNOWN_VCT")

	// ErrInternalServerError error for internal server error
	ErrInternalServerError = NewError("INTERNAL_SERVER_ERROR")

	// ErrDocumentValidationFailed error for document validation failed
	ErrDocumentValidationFailed = NewError("DOCUMENT_VALIDATION_FAILED")
)

Functions

func Check

func Check(ctx context.Context, cfg *model.Cfg, s any, log *logger.Log) error

Check checks for validation error

func CheckSimple

func CheckSimple(s any) error

CheckSimple checks for validation error with a simpler signature

func HostFromURL

func HostFromURL(rawURL string) (string, error)

HostFromURL extracts the host (including any port) from a URL string. Unlike strings.TrimLeft, this correctly handles all URL schemes and paths.

func NewValidator

func NewValidator() (*validator.Validate, error)

NewValidator creates a new validator

func Problem404

func Problem404() *problems.Problem

func ValidateDocumentData

func ValidateDocumentData(ctx context.Context, completeDocument *model.CompleteDocument, log *logger.Log) error

ValidateDocumentData validates DocumentData against the schemaRef in MetaData.DocumentDataValidationRef

Types

type Error

type Error struct {
	Title      string `json:"title"`
	Err        any    `json:"details"`
	HTTPStatus int    `json:"-"` // HTTP status code to return, 0 means auto-detect
}

Error is a struct that represents an error

func NewError

func NewError(title string) *Error

func NewErrorDetails

func NewErrorDetails(title string, err any) *Error

func NewErrorDetailsWithStatus

func NewErrorDetailsWithStatus(title string, err any, httpStatus int) *Error

NewErrorDetailsWithStatus creates a new Error with details and an explicit HTTP status code

func NewErrorFromError

func NewErrorFromError(err error) *Error

NewErrorFromError creates a new Error from an error

func NewErrorWithStatus

func NewErrorWithStatus(title string, httpStatus int) *Error

NewErrorWithStatus creates a new Error with an explicit HTTP status code

func (*Error) Error

func (e *Error) Error() string

type ErrorResponse

type ErrorResponse struct {
	Error *Error `json:"error"`
}

ErrorResponse is a struct that represents an error response in JSON from REST API

Jump to

Keyboard shortcuts

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