Documentation
¶
Index ¶
- Constants
- func ValidatePhoneNumber(s string) error
- type Email
- func (e Email) MarshalJSON() ([]byte, error)
- func (e Email) MarshalText() ([]byte, error)
- func (e *Email) Scan(value any) error
- func (e Email) String() string
- func (e *Email) UnmarshalJSON(b []byte) error
- func (e *Email) UnmarshalText(text []byte) error
- func (e Email) Validate() error
- func (e Email) Value() (driver.Value, error)
- type Language
- type Locale
- type ModelWithCursor
- type Optional
- type PhoneNumber
- func (p PhoneNumber) MarshalJSON() ([]byte, error)
- func (p PhoneNumber) MarshalText() ([]byte, error)
- func (p *PhoneNumber) Scan(value any) error
- func (p PhoneNumber) String() string
- func (p *PhoneNumber) UnmarshalJSON(b []byte) error
- func (p *PhoneNumber) UnmarshalText(text []byte) error
- func (p PhoneNumber) Validate() error
- func (p PhoneNumber) Value() (driver.Value, error)
- type UnixSeconds
- func (us UnixSeconds) FormatDate() string
- func (us UnixSeconds) FormatDateInTimezone(tz string) (string, error)
- func (us UnixSeconds) IsZero() bool
- func (us UnixSeconds) MarshalJSON() ([]byte, error)
- func (us *UnixSeconds) Scan(v any) error
- func (us UnixSeconds) Time() time.Time
- func (us *UnixSeconds) UnmarshalJSON(data []byte) error
- func (us UnixSeconds) Value() (driver.Value, error)
Constants ¶
const DEFAULT_LOCALE = "en-US"
Variables ¶
This section is empty.
Functions ¶
func ValidatePhoneNumber ¶ added in v1.5.1
Types ¶
type Email ¶ added in v1.5.1
type Email string
func (Email) MarshalJSON ¶ added in v1.5.1
func (Email) MarshalText ¶ added in v1.5.1
func (*Email) UnmarshalJSON ¶ added in v1.5.1
func (*Email) UnmarshalText ¶ added in v1.5.1
type Locale ¶ added in v1.5.1
type Locale string
Locale is a string type with validation
func NewLocaleString ¶ added in v1.5.1
NewLocaleString creates a validated locale string from a single BCP 47 tag ("es-MX") or a full Accept-Language header ("es-MX,es;q=0.9,en;q=0.8"). Tags are tried in the user's preference order: the first one with a supported language wins, keeping its region when it has an explicit one. Unsupported or malformed input falls back to DEFAULT_LOCALE instead of returning an error.
func (Locale) MarshalJSON ¶ added in v1.5.1
MarshalJSON implements json.Marshaler
func (*Locale) UnmarshalJSON ¶ added in v1.5.1
UnmarshalJSON implements json.Unmarshaler
type ModelWithCursor ¶
type ModelWithCursor interface {
GetCursor() string
}
type Optional ¶ added in v1.31.0
Optional is a request body field that records whether the key was present. Absent: Set is false. null: Set and Null are true. A value: Set is true and Value holds it. Body fields only, never a parameter.
The api reflector documents Optional[T] as T's schema made nullable, through the OptionalType method.
func (Optional[T]) IsZero ¶ added in v1.31.0
IsZero reports whether the key was absent, so a field tagged omitzero is dropped when marshalling.
func (Optional[T]) MarshalJSON ¶ added in v1.31.0
MarshalJSON writes null when the Optional is unset or null, else Value.
func (Optional[T]) OptionalType ¶ added in v1.31.0
OptionalType returns T. The api reflector finds Optional by this method, so this package does not depend on the api packages.
func (*Optional[T]) UnmarshalJSON ¶ added in v1.31.0
UnmarshalJSON records the key as present: null sets Null, anything else decodes into Value. encoding/json only calls it for keys in the body, so an absent key leaves Set false. An ez error from T's own decoder is returned as T's decoder wrote it, its code, message and data kept, so the field answers as T alone would. Any other decode error is EINVALID, like the other types in this package.
type PhoneNumber ¶ added in v1.5.1
type PhoneNumber string
func NewPhoneNumber ¶ added in v1.5.1
func NewPhoneNumber(s string) (PhoneNumber, error)
NewPhoneNumber validates and returns a PhoneNumber.
func (PhoneNumber) MarshalJSON ¶ added in v1.5.1
func (p PhoneNumber) MarshalJSON() ([]byte, error)
func (PhoneNumber) MarshalText ¶ added in v1.5.1
func (p PhoneNumber) MarshalText() ([]byte, error)
func (*PhoneNumber) Scan ¶ added in v1.5.1
func (p *PhoneNumber) Scan(value any) error
func (PhoneNumber) String ¶ added in v1.5.1
func (p PhoneNumber) String() string
func (*PhoneNumber) UnmarshalJSON ¶ added in v1.5.1
func (p *PhoneNumber) UnmarshalJSON(b []byte) error
func (*PhoneNumber) UnmarshalText ¶ added in v1.5.1
func (p *PhoneNumber) UnmarshalText(text []byte) error
func (PhoneNumber) Validate ¶ added in v1.5.1
func (p PhoneNumber) Validate() error
Validate re-validates the value (useful after deserialization).
type UnixSeconds ¶ added in v1.5.2
type UnixSeconds int64
UnixSeconds is seconds since Unix epoch (1970-01-01T00:00:00Z)
func UnixSecondsFromRFC3339 ¶ added in v1.5.2
func UnixSecondsFromRFC3339(dateString string) (UnixSeconds, error)
UnixSecondsFromRFC3339 parses an RFC3339/RFC3339Nano string into Unix seconds
func UnixSecondsFromTime ¶ added in v1.5.2
func UnixSecondsFromTime(t time.Time) UnixSeconds
UnixSecondsFromTime converts a time.Time to Unix seconds (truncates sub-second)
func UnixSecondsNow ¶ added in v1.5.2
func UnixSecondsNow() UnixSeconds
UnixSecondsNow returns the current time in Unix seconds
func (UnixSeconds) FormatDate ¶ added in v1.5.2
func (us UnixSeconds) FormatDate() string
FormatDate returns dd/mm/yyyy
func (UnixSeconds) FormatDateInTimezone ¶ added in v1.5.2
func (us UnixSeconds) FormatDateInTimezone(tz string) (string, error)
FormatDateInTimezone returns dd/mm/yyyy rendered in the provided IANA timezone
func (UnixSeconds) IsZero ¶ added in v1.5.2
func (us UnixSeconds) IsZero() bool
IsZero reports whether us == 0
func (UnixSeconds) MarshalJSON ¶ added in v1.5.2
func (us UnixSeconds) MarshalJSON() ([]byte, error)
MarshalJSON emits a JSON number (unix seconds)
func (*UnixSeconds) Scan ¶ added in v1.5.2
func (us *UnixSeconds) Scan(v any) error
Scan implements sql.Scanner for BIGINT (and a few driver variants).
func (UnixSeconds) Time ¶ added in v1.5.2
func (us UnixSeconds) Time() time.Time
Time converts UnixSeconds back to time.Time
func (*UnixSeconds) UnmarshalJSON ¶ added in v1.5.2
func (us *UnixSeconds) UnmarshalJSON(data []byte) error
UnmarshalJSON accepts unix seconds written as a JSON integer without a fraction or an exponent that fits in an int64, and null, which sets 0. It refuses anything else, 1.0 and 1e3 included, with one EINVALID.