Initial commit: Open sourcing all of the Maple Open Technologies code.
This commit is contained in:
commit
755d54a99d
2010 changed files with 448675 additions and 0 deletions
|
|
@ -0,0 +1,53 @@
|
|||
package tenant
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"codeberg.org/mapleopentech/monorepo/cloud/maplepress-backend/pkg/validation"
|
||||
)
|
||||
|
||||
// CreateRequest represents the HTTP request for creating a tenant
|
||||
type CreateRequest struct {
|
||||
Name string `json:"name"`
|
||||
Slug string `json:"slug"`
|
||||
}
|
||||
|
||||
// Validate validates the create tenant request
|
||||
// CWE-20: Improper Input Validation
|
||||
func (r *CreateRequest) Validate() error {
|
||||
validator := validation.NewValidator()
|
||||
|
||||
// Validate name: 3-100 chars, printable, no HTML
|
||||
if err := validator.ValidateRequired(r.Name, "name"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validator.ValidateLength(r.Name, "name", 3, 100); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validator.ValidatePrintable(r.Name, "name"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validator.ValidateNoHTML(r.Name, "name"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Validate slug: uses existing slug validation (lowercase, hyphens, 3-63 chars)
|
||||
if err := validator.ValidateSlug(r.Slug, "slug"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Sanitize inputs
|
||||
r.Name = validator.SanitizeString(r.Name)
|
||||
r.Slug = validator.SanitizeString(r.Slug)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CreateResponse represents the HTTP response after creating a tenant
|
||||
type CreateResponse struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Slug string `json:"slug"`
|
||||
Status string `json:"status"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package tenant
|
||||
|
||||
import "time"
|
||||
|
||||
// GetResponse represents the HTTP response when retrieving a tenant
|
||||
type GetResponse struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Slug string `json:"slug"`
|
||||
Status string `json:"status"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue