Documentation ¶
Index ¶
- Variables
- type DriversLicense
- type PhoneNumber
- type RFC3339Nano
- func (t *RFC3339Nano) Format(format string) string
- func (RFC3339Nano) JSONSchemaDescribe() jsonschema.Property
- func (t RFC3339Nano) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (t RFC3339Nano) MarshalJSON() ([]byte, error)
- func (t RFC3339Nano) Time() time.Time
- func (t RFC3339Nano) ToPtr() *RFC3339Nano
- func (t *RFC3339Nano) UnmarshalBSONValue(valueType bsontype.Type, data []byte) error
- func (t *RFC3339Nano) UnmarshalJSON(b []byte) error
Constants ¶
This section is empty.
Variables ¶
var DriversLicenses = []DriversLicense{ NewDriversLicense("AM"), NewDriversLicense("A1"), NewDriversLicense("A2"), NewDriversLicense("A"), NewDriversLicense("B"), NewDriversLicense("BE"), NewDriversLicense("B1"), NewDriversLicense("C1"), NewDriversLicense("C1E"), NewDriversLicense("C"), NewDriversLicense("CE"), NewDriversLicense("D1"), NewDriversLicense("D1E"), NewDriversLicense("D"), NewDriversLicense("DE"), NewDriversLicense("LK"), NewDriversLicense("S"), NewDriversLicense("BF17"), NewDriversLicense("L17"), NewDriversLicense("TR"), NewDriversLicense("TROL"), NewDriversLicense("H"), NewDriversLicense("TRAM"), NewDriversLicense("V"), NewDriversLicense("F"), NewDriversLicense("T"), NewDriversLicense("TM"), NewDriversLicense("K"), NewDriversLicense("L"), NewDriversLicense("G"), NewDriversLicense("W"), }
DriversLicenses contains all the EU drivers licenses List obtained from https://en.wikipedia.org/wiki/European_driving_licence
var ErrInvalidDriversLicense = errors.New("invalid drivers license")
ErrInvalidDriversLicense is returned when a drivers license is invalid
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 ¶
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