types

package module
v0.0.0-...-55d1cb7 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 5 Imported by: 7 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Go Reference Code Coverage License

Code Coverage

This library offers a collection of commonly used data types in API contexts, ensuring correct marshalling, unmarshalling, and validation. By standardizing these types across all our API libraries, we aim to reduce redundancy, increase consistency, and enhance type safety.

Features

  • Standardized Types: Tailored for API data interchange
  • Validation: Built-in validation rules to ensure data integrity before processing or transmission.
  • JSON Marshalling/Unmarshalling: Custom JSON handling for each type to handle special cases (e.g., ensuring email addresses are formatted correctly).
  • Used Across go-api-libs: These types are employed by all API libraries within the go-api-libs organization for consistency.

Usage

To install the library, use the following command:

go get github.com/go-api-libs/types

When using any of the API libraries from the go-api-libs organization, you can trust that types in successful API responses are valid.

Beyond that, here's how you can use some types from this library:

package main

import (
	"fmt"

	"github.com/go-api-libs/types"
)

func main() {
	// Using Email type
	email := types.Email("user@example.com")
	if err := email.Validate(); err != nil {
		fmt.Println(err)
	} else {
		fmt.Println("Valid email address")
	}
}

Additional Information

Contributing

Contributions are welcome — please open an issue or a pull request on GitHub.

License

This project is licensed under the Apache 2.0 License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidEmail = errors.New("invalid email")

ErrInvalidEmail is returned when an email is invalid.

Functions

This section is empty.

Types

type Email

type Email string

Email is a string that represents an email address.

func (*Email) UnmarshalJSONFrom

func (e *Email) UnmarshalJSONFrom(dec *jsontext.Decoder) error

func (Email) Validate

func (e Email) Validate() error

Validate checks if the email is valid.

Jump to

Keyboard shortcuts

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