valueobject

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidEmail = errors.New("not a valid email address")
)

EmailAddress errors

View Source
var (
	ErrInvalidURL = errors.New("not a valid URL")
)

EmailAddress errors

Functions

This section is empty.

Types

type AggregateType

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

func NewAggregateType

func NewAggregateType(value string) (AggregateType, error)

NewAggregateType creates a new valid aggregate type value object.

func (AggregateType) Equals

func (v AggregateType) Equals(value Value) bool

Equals checks that two value objects are the same.

func (AggregateType) MarshalText

func (v AggregateType) MarshalText() ([]byte, error)

MarshalText used to serialize the object

func (AggregateType) String

func (v AggregateType) String() string

String implements the fmt.Stringer interface.

func (*AggregateType) UnmarshalText

func (v *AggregateType) UnmarshalText(b []byte) error

UnmarshalText used to deserialize the object and returns an error if it's invalid.

type Description

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

func NewDescription

func NewDescription(value string) (Description, error)

NewDescription creates a new valid description object.

func (Description) Equals

func (v Description) Equals(value Value) bool

Equals checks that two value objects are the same.

func (Description) MarshalText

func (v Description) MarshalText() ([]byte, error)

MarshalText used to serialize the object

func (Description) String

func (v Description) String() string

String implements the fmt.Stringer interface.

func (*Description) UnmarshalText

func (v *Description) UnmarshalText(b []byte) error

UnmarshalText used to deserialize the object and returns an error if it's invalid.

type Email

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

Email represents a valid email address.

func NewEmail

func NewEmail(email string) (Email, error)

NewEmail creates a new email address.

func ZeroEmail

func ZeroEmail() Email

ZeroEmail represents the zero value for an email value object.

func (Email) Equals

func (v Email) Equals(value Value) bool

Equals checks that two email addresses are the same.

Example
package main

import (
	"fmt"
	"github.com/dasch-swiss/dasch-service-platform/shared/go/pkg/valueobject"
)

func main() {
	a, _ := valueobject.NewEmail("joe@blogs.com")
	b, _ := valueobject.NewEmail("joe@blogs.com")

	fmt.Println(a.Equals(b))
}
Output:

true

func (Email) MarshalText

func (v Email) MarshalText() ([]byte, error)

MarshalText used to serialize the object

func (Email) String

func (v Email) String() string

String returns string representation of the email address.

Example
package main

import (
	"fmt"
	"github.com/dasch-swiss/dasch-service-platform/shared/go/pkg/valueobject"
)

func main() {
	e, _ := valueobject.NewEmail("joe@blogs.com")

	fmt.Println(e.String())
}
Output:

joe@blogs.com

func (*Email) UnmarshalText

func (v *Email) UnmarshalText(b []byte) error

UnmarshalText used to deserialize the object and returns an error if it's invalid.

type FamilyName

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

func NewFamilyName

func NewFamilyName(value string) (FamilyName, error)

NewGivenName creates a new valid given name object.

func (FamilyName) Equals

func (v FamilyName) Equals(value Value) bool

Equals checks that two value objects are the same.

func (FamilyName) MarshalText

func (v FamilyName) MarshalText() ([]byte, error)

MarshalText used to serialize the object

func (FamilyName) String

func (v FamilyName) String() string

String implements the fmt.Stringer interface.

func (*FamilyName) UnmarshalText

func (v *FamilyName) UnmarshalText(b []byte) error

UnmarshalText used to deserialize the object and returns an error if it's invalid.

type GivenName

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

func NewGivenName

func NewGivenName(value string) (GivenName, error)

NewGivenName creates a new valid given name object.

func (GivenName) Equals

func (v GivenName) Equals(value Value) bool

Equals checks that two value objects are the same.

func (GivenName) MarshalText

func (v GivenName) MarshalText() ([]byte, error)

MarshalText used to serialize the object

func (GivenName) String

func (v GivenName) String() string

String implements the fmt.Stringer interface.

func (*GivenName) UnmarshalText

func (v *GivenName) UnmarshalText(b []byte) error

UnmarshalText used to deserialize the object and returns an error if it's invalid.

type Identifier

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

func IdentifierFromBytes added in v1.2.0

func IdentifierFromBytes(input []byte) (Identifier, error)

IdentifierFromBytes creates an identifier value object from the provided byte array

func NewIdentifier

func NewIdentifier() (Identifier, error)

NewIdentifier creates a new identifier value object

func (Identifier) Equals

func (v Identifier) Equals(value Value) bool

Equals tests for equality with another value object

func (Identifier) MarshalText

func (v Identifier) MarshalText() ([]byte, error)

MarshalText used to serialize the object

func (Identifier) String

func (v Identifier) String() string

String implements the fmt.Stringer interface.

func (Identifier) UUID

func (v Identifier) UUID() uuid.UUID

AsUUID returns the UUID of the identifier.

func (*Identifier) UnmarshalText

func (v *Identifier) UnmarshalText(b []byte) error

UnmarshalText used to deserialize the object and returns an error if it's invalid.

type LongName

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

func NewLongName

func NewLongName(value string) (LongName, error)

NewLongName creates a new valid long name object.

func (LongName) Equals

func (v LongName) Equals(value Value) bool

Equals checks that two value objects are the same.

func (LongName) MarshalText

func (v LongName) MarshalText() ([]byte, error)

MarshalText used to serialize the object

func (LongName) String

func (v LongName) String() string

String implements the fmt.Stringer interface.

func (*LongName) UnmarshalText

func (v *LongName) UnmarshalText(b []byte) error

UnmarshalText used to deserialize the object and returns an error if it's invalid.

type Password

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

func NewPassword

func NewPassword(value string) (Password, error)

NewPassword creates a new valid password object.

func (Password) Equals

func (v Password) Equals(value Value) bool

Equals checks that two value objects are the same.

func (Password) MarshalText

func (v Password) MarshalText() ([]byte, error)

MarshalText used to serialize the object

func (Password) String

func (v Password) String() string

String implements the fmt.Stringer interface.

func (*Password) UnmarshalText

func (v *Password) UnmarshalText(b []byte) error

UnmarshalText used to deserialize the object and returns an error if it's invalid.

type ShortCode

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

func NewShortCode

func NewShortCode(value string) (ShortCode, error)

NewShortCode creates a new valid short code object.

func (ShortCode) Equals

func (v ShortCode) Equals(value Value) bool

Equals checks that two value objects are the same.

func (ShortCode) MarshalText

func (v ShortCode) MarshalText() ([]byte, error)

MarshalText used to serialize the object

func (ShortCode) String

func (v ShortCode) String() string

String implements the fmt.Stringer interface.

func (*ShortCode) UnmarshalText

func (v *ShortCode) UnmarshalText(b []byte) error

UnmarshalText used to deserialize the object and returns an error if it's invalid.

type ShortName

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

func NewShortName

func NewShortName(value string) (ShortName, error)

NewShortName creates a new valid short name object.

func (ShortName) Equals

func (v ShortName) Equals(value Value) bool

Equals checks that two value objects are the same.

func (ShortName) MarshalText

func (v ShortName) MarshalText() ([]byte, error)

MarshalText used to serialize the object

func (ShortName) String

func (v ShortName) String() string

String implements the fmt.Stringer interface.

func (*ShortName) UnmarshalText

func (v *ShortName) UnmarshalText(b []byte) error

UnmarshalText used to deserialize the object and returns an error if it's invalid.

type Timestamp

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

func NewTimestamp

func NewTimestamp() Timestamp

NewTimestamp creates a new timestamp value object

func NewTimestampFromUnix

func NewTimestampFromUnix(sec int64) Timestamp

NewTimestampFromUnix creates a new timestamp value object for the supplied unix time in seconds.

func (Timestamp) Equals

func (v Timestamp) Equals(value Value) bool

Equals tests for equality with another value object

func (Timestamp) MarshalJSON

func (v Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON used to serialize the object

func (Timestamp) MarshalText

func (v Timestamp) MarshalText() ([]byte, error)

MarshalText used to serialize the object

func (Timestamp) String

func (v Timestamp) String() string

String implements the fmt.Stringer interface.

func (Timestamp) Time

func (v Timestamp) Time() time.Time

Time returns the Time of the value.

func (Timestamp) Unix

func (v Timestamp) Unix() int64

Unix returns the Unix time of the value in number of seconds.

func (*Timestamp) UnmarshalJSON

func (v *Timestamp) UnmarshalJSON(b []byte) error

UnmarshalJSON used to deserialize the object and returns an error if it's invalid.

func (*Timestamp) UnmarshalText

func (v *Timestamp) UnmarshalText(b []byte) error

UnmarshalText used to deserialize the object and returns an error if it's invalid.

type URL

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

URL represents a valid URL address.

func NewURL

func NewURL(value string) (URL, error)

NewURL creates a new URL.

func ZeroURL

func ZeroURL() URL

ZeroURL represents the zero value for an URL value object.

func (URL) Equals

func (u URL) Equals(value Value) bool

Equals checks that two URL addresses are the same.

func (URL) String

func (u URL) String() string

String returns string representation of the URL.

type Username

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

func NewUsername

func NewUsername(value string) (Username, error)

NewUsername creates a new valid username object.

func (Username) Equals

func (v Username) Equals(value Value) bool

Equals checks that two value objects are the same.

func (Username) MarshalText

func (v Username) MarshalText() ([]byte, error)

MarshalText used to serialize the object

func (Username) String

func (v Username) String() string

String implements the fmt.Stringer interface.

func (*Username) UnmarshalText

func (v *Username) UnmarshalText(b []byte) error

UnmarshalText used to deserialize the object and returns an error if it's invalid.

type Value

type Value interface {
	fmt.Stringer
	Equals(value Value) bool
}

Value object, includes method String() from fmt.Stringer

Jump to

Keyboard shortcuts

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