jsonHelpers

package
v1.0.31 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

DriversLicenses contains all the EU drivers licenses List obtained from https://en.wikipedia.org/wiki/European_driving_licence

View Source
var ErrInvalidDriversLicense = errors.New("invalid drivers license")

ErrInvalidDriversLicense is returned when a drivers license is invalid

View Source
var ErrInvalidPhoneNumber = errors.New("invalid phone number")

ErrInvalidPhoneNumber is the error returned if the input phone is incorrect

Functions

This section is empty.

Types

type DriversLicense

type DriversLicense [4]byte

DriversLicense contains a European drivers license

Why a 4 byte array?

  • Fixed byte arrays are much faster than strings
  • The drivers license code is never longer than 4 bytes

func NewDriversLicense

func NewDriversLicense(name string) DriversLicense

NewDriversLicense creates a DriversLicense from a string

func (DriversLicense) JSONSchemaDescribe

func (DriversLicense) JSONSchemaDescribe() jsonschema.Property

JSONSchemaDescribe implements jsonschema.Describe

func (DriversLicense) MarshalJSON

func (dl DriversLicense) MarshalJSON() ([]byte, error)

MarshalJSON transforms a drivers license into a json string

func (DriversLicense) String

func (dl DriversLicense) String() string

Strings converts a drivers license identifier into a string

func (*DriversLicense) UnmarshalJSON

func (dl *DriversLicense) UnmarshalJSON(b []byte) error

UnmarshalJSON transforms reads a string and converts it into a drivers license

type PhoneNumber

type PhoneNumber struct {
	IsLocal          bool   // 06 12345678
	HasCountryPrefix bool   // +31 6 12345678
	Number           uint64 // 612345678 (basically the number without any formatting)
}

PhoneNumber represens a phone number

func (PhoneNumber) JSONSchemaDescribe

func (PhoneNumber) JSONSchemaDescribe() jsonschema.Property

JSONSchemaDescribe implements jsonschema.Describe

func (PhoneNumber) MarshalJSON

func (n PhoneNumber) MarshalJSON() ([]byte, error)

MarshalJSON transforms a phonenumber into a json string

func (PhoneNumber) String

func (n PhoneNumber) String() string

String converts the phone number into a string

func (*PhoneNumber) UnmarshalJSON

func (n *PhoneNumber) UnmarshalJSON(b []byte) error

UnmarshalJSON transforms reads a string and converts it into a

type RFC3339Nano

type RFC3339Nano time.Time

RFC3339Nano is a time.Time that json (Un)Marshals from & to RFC3339 nano

func (*RFC3339Nano) Format

func (t *RFC3339Nano) Format(format string) string

Format formats the time according to the format string

func (RFC3339Nano) JSONSchemaDescribe

func (RFC3339Nano) JSONSchemaDescribe() jsonschema.Property

JSONSchemaDescribe implements jsonschema.Describe

func (RFC3339Nano) MarshalBSONValue

func (t RFC3339Nano) MarshalBSONValue() (bsontype.Type, []byte, error)

MarshalBSONValue implements bson.ValueMarshaler by default RFC3339Nano is transformed to a empty map so here we fix that

func (RFC3339Nano) MarshalJSON

func (t RFC3339Nano) MarshalJSON() ([]byte, error)

MarshalJSON transforms a into t into a RFC3339 time string

func (RFC3339Nano) Time

func (t RFC3339Nano) Time() time.Time

Time returns the underlaying time object

func (RFC3339Nano) ToPtr

func (t RFC3339Nano) ToPtr() *RFC3339Nano

ToPtr creates a pointer to t This is handy when you want to add a inline time to a struct field

func (*RFC3339Nano) UnmarshalBSONValue

func (t *RFC3339Nano) UnmarshalBSONValue(valueType bsontype.Type, data []byte) error

UnmarshalBSONValue implements bson.ValueUnmarshaler by default RFC3339Nano is transformed to a empty map so here we fix that

func (*RFC3339Nano) UnmarshalJSON

func (t *RFC3339Nano) UnmarshalJSON(b []byte) error

UnmarshalJSON transforms a RFC3339 string into *a

Jump to

Keyboard shortcuts

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