validation

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValidationOption

func GetValidationOption(opts []Option, id OptionKey) (any, error)

GetValidationOption returns a validation option given an ID

func ValidateCredential

func ValidateCredential(cred credential.VerifiableCredential, _ ...Option) error

ValidateCredential verifies a credential's object model depending on the struct tags used on VerifiableCredential

func ValidateExpiry

func ValidateExpiry(cred credential.VerifiableCredential, _ ...Option) error

ValidateExpiry verifies a credential's expiry date is not in the past. We assume the date is parseable as an RFC3339 date time value.

func ValidateJSONSchema

func ValidateJSONSchema(cred credential.VerifiableCredential, opts ...Option) error

ValidateJSONSchema verifies a credential's data against a Verifiable Credential JSON Schema There is a required single option which is a string JSON value representing the Credential Schema Object

Types

type CredentialValidator

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

func NewCredentialValidator

func NewCredentialValidator(validators []Validator) (*CredentialValidator, error)

NewCredentialValidator creates a new credential validator which executes in the order of the validators provided The validators introspect the contents of the credential, and do not handle signature verification.

func (*CredentialValidator) ValidateCredential

func (cv *CredentialValidator) ValidateCredential(cred credential.VerifiableCredential, opts ...Option) error

ValidateCredential validates a credential given a credential validator

type Option

type Option struct {
	ID     OptionKey
	Option any
}

Option represents a single option that may be required for a validator

func WithSchema

func WithSchema(schema string) Option

WithSchema provides a schema as a validation option

type OptionKey

type OptionKey string

OptionKey uniquely represents an option to be used in a validator

const (
	SchemaOption OptionKey = "schema"
)

type Validate

type Validate func(cred credential.VerifiableCredential, opts ...Option) error

type Validator

type Validator struct {
	ID           string
	ValidateFunc Validate
}

func GetKnownVerifiers

func GetKnownVerifiers() []Validator

Jump to

Keyboard shortcuts

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