Documentation
¶
Overview ¶
Package validate provides shared validation rules and helpers for the application.
Index ¶
- Constants
- Variables
- func IsListTool(group, op string) bool
- func SkillCompatibility(compatibility string) error
- func SkillDescription(description string) error
- func SkillDocument(name, description, compatibility, dirName string) error
- func SkillIdentity(name, description, dirName string) error
- func SkillName(name string) error
- func SkillNameMatchesDir(name, dirName string) error
- func ValidateVar(v any, tag string) error
- type SkillFrontmatter
Constants ¶
const ( // Text field limits TitleMaxLen = 200 DescMaxLen = 2000 NameMaxLen = 100 // URL limits URLMaxLen = 2048 // Tag limits TagMaxLen = 50 MaxTagsCount = 50 MinTagLen = 1 // Query limits QueryMaxLen = 100 // CursorMaxLen is the max length for opaque pagination cursors (HMAC-signed // EncodeCursor tokens). Distinct from QueryMaxLen — search text stays short; // cursors routinely exceed 100 characters. CursorMaxLen = 4096 MaxSearchLimit = 100 // File upload limits MaxFileSizeMB = 10 MaxFileSizeBytes = MaxFileSizeMB * 1024 * 1024 MaxFileCount = 10 )
Common validation constants
const ( // Required title: non-empty, max 200 chars TagTitle = "required,min=1,max=200" // Optional title: if provided, max 200 chars TagTitleOptional = "omitempty,min=1,max=200" // Required description: non-empty, max 2000 chars TagDescription = "required,min=1,max=2000" // Optional description: if provided, max 2000 chars TagDescriptionOptional = "omitempty,max=2000" // Required URL: valid URL format, max 2048 chars TagURL = "required,url,max=2048" // Optional URL: if provided, valid URL format TagURLOptional = "omitempty,url,max=2048" // Positive integer ID (for IDs that must be > 0) TagID = "required,gte=1" // Optional positive integer ID TagIDOptional = "omitempty,gte=1" // Non-negative integer TagNonNegative = "gte=0" // Required non-empty string TagRequired = "required,min=1" // Tag list: required, each tag 1-50 chars, max 50 tags TagList = "required,dive,min=1,max=50" )
Common validation tags for reuse in struct definitions
const ( SkillNameMaxLen = 64 SkillDescMaxLen = 1024 SkillCompatibilityMaxLen = 500 )
Agent Skills limits from https://agentskills.io/specification (skills-ref).
Variables ¶
var Validate = validator.New()
Validate is the global validator instance
Functions ¶
func IsListTool ¶
IsListTool reports whether group.op is a paged list. Capability operations match when the name contains "list". Pipeline, workflow, and function list, plus hub apps, are paged too.
func SkillCompatibility ¶
SkillCompatibility checks an optional compatibility field (≤ SkillCompatibilityMaxLen runes).
func SkillDescription ¶
SkillDescription checks a skill description (required, ≤ SkillDescMaxLen runes).
func SkillDocument ¶
SkillDocument checks Agent Skills identity fields including optional compatibility.
func SkillIdentity ¶
SkillIdentity checks name, description, and optional directory match together.
func SkillName ¶
SkillName checks a skill name against the Agent Skills naming rules.
Rules: 1–64 characters; lowercase letters, digits, and hyphens only; must not start or end with a hyphen; must not contain consecutive hyphens.
func SkillNameMatchesDir ¶
SkillNameMatchesDir reports whether name equals the skill directory basename. dirName of "" or "." skips the check (root-level SKILL.md imports).
func ValidateVar ¶
ValidateVar validates a single variable against a tag
Types ¶
type SkillFrontmatter ¶
type SkillFrontmatter struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Compatibility string `yaml:"compatibility"`
}
SkillFrontmatter is the YAML header of a SKILL.md file.
func ParseSkillMarkdown ¶
func ParseSkillMarkdown(raw string) (SkillFrontmatter, string, error)
ParseSkillMarkdown splits SKILL.md into YAML frontmatter and markdown body.