models

package
v0.0.0-...-0f5ba4b Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MovementValidator validator.Func = func(fl validator.FieldLevel) bool {

	rule := regexp.MustCompile(`^\w+(\s+\w+)*$`)
	matches := rule.FindAllString(fl.Field().String(), -1)

	return len(matches) == 1
}

MovementValidator validates the movement field in a Set. Returns true if valid, else false.

Functions

func BindingErrorToMessage

func BindingErrorToMessage(err error) string

BindingErrorToMessage turns a binding error from a set field into a a readable message on the field's constraints.

func ContainsSet

func ContainsSet(sets []*Set, s *Set) bool

ContainsSet checks if the slice of sets contains the provided set.

func ContainsUser

func ContainsUser(users []*User, s *User) bool

ContainsUser checks if the slice of users contains the provided user.

func SetsEqual

func SetsEqual(set1, set2 *Set) bool

SetsEqual returns true if all non-id fields of the set are equal, and false otherwise.

func UsersEqual

func UsersEqual(user1, user2 *User) bool

UsersEqual returns true if all non-id fields of the user are equal, and false otherwise.

Types

type Credentails

type Credentails struct {
	UID      UserID `json:"user-id"`
	Password string `json:"password,omitempty"`
}

type Set

type Set struct {
	// the id for this set
	//
	// required: true
	// min: 1
	ID            SetID   `json:"set-id"`
	UID           UserID  `json:"user-id,omitempty"`
	Movement      string  `json:"movement" binding:"movement"`
	Volume        float64 `json:"volume" binding:"gt=0"`
	Intensity     float64 `json:"intensity" binding:"gt=0,lte=100"`
	CreatedOn     string  `json:"-"`
	LastUpdatedOn string  `json:"-"`
}

Set is the model representation of a sets resource swagger:model

type SetID

type SetID int

SetID is the unique int identifier assigned to sets when added to the SetDB

type User

type User struct {
	ID       UserID `json:"user-id"`
	Name     string `json:"name"`
	Password string `json:"password,omitempty"`
}

User defines the model of the user resource

type UserID

type UserID int

UserID is the unique identifier for a user of the application

Jump to

Keyboard shortcuts

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