Documentation ¶
Overview ¶
Package model holds the various types and interfaces for Parrot.
Index ¶
- Variables
- func HasMinLength(str string, min int) bool
- func NewValidationError(errs []errors.Error) error
- func ValidEmail(str string) bool
- type Locale
- type LocaleInfo
- type LocaleStorer
- type Project
- type ProjectClient
- type ProjectClientStorer
- type ProjectLocaleStorer
- type ProjectStorer
- type ProjectUser
- type ProjectUserStorer
- type User
- type UserStorer
- type Validatable
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLocaleIdent = &errors.Error{ Type: "InvalidLocaleIdent", Message: "invalid field locale ident"} ErrInvalidLocaleLanguage = &errors.Error{ Type: "InvalidLocaleLanguage", Message: "invalid field locale language"} ErrInvalidLocaleCountry = &errors.Error{ Type: "InvalidLocaleCountry", Message: "invalid field locale country"} )
var ( ErrInvalidClientName = &errors.Error{ Type: "InvalidClientName", Message: "invalid field name"} ErrInvalidProjectID = &errors.Error{ Type: "InvalidProjectID", Message: "invalid field project_id"} )
var ( ErrInvalidEmail = &errors.Error{ Type: "InvalidEmail", Message: "invalid email"} ErrInvalidName = &errors.Error{ Type: "InvalidName", Message: "invalid name"} ErrInvalidPassword = &errors.Error{ Type: "InvalidPassword", Message: "invalid password"} )
var (
ErrInvalidProjectName = &errors.Error{
Type: "InvalidProjectName",
Message: "invalid field project name"}
)
var (
ErrValidationFailure = &errors.Error{
Type: "ValidationFailure",
Message: "data validation failed"}
)
var Locales = map[string]LocaleInfo{}/* 110 elements not displayed */
Locales is mapping of standard locale idents to LocaleInfo
Functions ¶
func HasMinLength ¶
HasMinLength returns true if the string's length is greater than or equal to the min parameter.
func NewValidationError ¶
NewValidationError constructs and returns a new error.
func ValidEmail ¶
ValidEmail returns true if the string is of the valid email format.
Types ¶
type Locale ¶
type Locale struct { ID string `db:"id" json:"id"` Ident string `db:"ident" json:"ident"` Language string `db:"language" json:"language"` Country string `db:"country" json:"country"` Pairs map[string]string `db:"pairs" json:"pairs"` ProjectID string `db:"project_id" json:"project_id"` }
type LocaleInfo ¶
LocaleInfo holds the data to specify a standard locale.
type LocaleStorer ¶
type LocaleStorer interface { CreateLocale(loc Locale) (*Locale, error) DeleteLocale(projID string, ident string) error }
LocaleStorer is the interface to store locales.
type Project ¶
type Project struct { ID string `db:"id" json:"id"` Name string `db:"name" json:"name"` Keys []string `db:"keys" json:"keys"` }
func (*Project) SanitizeKeys ¶
func (p *Project) SanitizeKeys()
SanitizeKeys removes empty and duplicate keys.
type ProjectClient ¶
type ProjectClient struct { ClientID string `db:"client_id" json:"client_id"` Name string `db:"name" json:"name"` Secret string `db:"secret" json:"secret,omitempty"` ProjectID string `db:"project_id" json:"project_id"` }
func (*ProjectClient) Validate ¶
func (p *ProjectClient) Validate() error
Validate returns an error if the project client's data is invalid.
type ProjectClientStorer ¶
type ProjectClientStorer interface { FindOneClient(string) (*ProjectClient, error) GetProjectClients(string) ([]ProjectClient, error) GetProjectClient(projectID, clientID string) (*ProjectClient, error) CreateProjectClient(ProjectClient) (*ProjectClient, error) UpdateProjectClientSecret(ProjectClient) (*ProjectClient, error) UpdateProjectClientName(ProjectClient) (*ProjectClient, error) DeleteProjectClient(projectID, clientID string) error }
ProjectClientStorer is the interface to store project clients.
type ProjectLocaleStorer ¶
type ProjectLocaleStorer interface { UpdateLocalePairs(projID string, localeIdent string, pairs map[string]string) (*Locale, error) GetProjectLocaleByIdent(projID string, localeIdent string) (*Locale, error) GetProjectLocales(projID string, localeIdents ...string) ([]Locale, error) }
ProjectLocaleStorer is the interface to store project locales.
type ProjectStorer ¶
type ProjectStorer interface { GetProject(string) (*Project, error) CreateProject(Project) (*Project, error) UpdateProject(Project) (*Project, error) DeleteProject(string) error UpdateProjectName(projectID, name string) (*Project, error) AddProjectKey(projectID, key string) (*Project, error) UpdateProjectKey(projectID, oldKey, newKey string) (*Project, int, error) DeleteProjectKey(projectID, key string) (*Project, error) }
ProjectStorer is the interface to store projects.
type ProjectUser ¶
type ProjectUserStorer ¶
type ProjectUserStorer interface { GetProjectUsers(projID string) ([]ProjectUser, error) GetUserProjects(userID string) ([]Project, error) GetProjectUser(projID, userID string) (*ProjectUser, error) AssignProjectUser(ProjectUser) (*ProjectUser, error) RevokeProjectUser(ProjectUser) error UpdateProjectUser(ProjectUser) (*ProjectUser, error) GetUserProjectRoles(projID string) ([]ProjectUser, error) }
ProjectUserStorer is the interface to store project users.
type User ¶
type UserStorer ¶
type UserStorer interface { GetUserByID(string) (*User, error) GetUserByEmail(string) (*User, error) CreateUser(User) (*User, error) UpdateUserPassword(User) (*User, error) UpdateUserName(User) (*User, error) UpdateUserEmail(User) (*User, error) }
UserStorer is the interface to store users.
type Validatable ¶
type Validatable interface {
Validate() error
}
Validatable specifies the interface to validate structs.