Vibe-guided bskyoauth and custom repo example code in Golang 馃 probably not safe to use in prod
1package bskyoauth
2
3import (
4 "github.com/shindakun/bskyoauth/internal/validation"
5)
6
7// ValidateHandle validates a Bluesky handle against AT Protocol specifications.
8// Handles must be valid domain names with specific constraints:
9// - Maximum 253 characters total
10// - Each segment (between dots) maximum 63 characters
11// - Only lowercase letters, digits, and hyphens allowed
12// - No trailing or leading dots
13// - TLD cannot start with a digit
14func ValidateHandle(handle string) error {
15 return validation.ValidateHandle(handle)
16}
17
18// ValidatePostText validates text for a Bluesky post.
19// Text must be:
20// - Non-empty
21// - Maximum 300 characters (grapheme clusters/runes)
22// - Valid UTF-8
23// - No null bytes
24func ValidatePostText(text string) error {
25 return validation.ValidatePostText(text)
26}
27
28// ValidateTextField validates a generic text field with custom length limits.
29// This is useful for custom record fields that have different length requirements.
30func ValidateTextField(text string, fieldName string, maxLength int) error {
31 return validation.ValidateTextField(text, fieldName, maxLength)
32}
33
34// ValidateRecordFields validates common fields in a record map.
35// This performs basic validation on standard fields like createdAt.
36func ValidateRecordFields(record map[string]interface{}) error {
37 return validation.ValidateRecordFields(record)
38}
39
40// ValidateCollectionNSID validates that a collection name is a valid NSID.
41// NSIDs are Namespaced Identifiers used in the AT Protocol to identify
42// record types (e.g., "app.bsky.feed.post").
43func ValidateCollectionNSID(collection string) error {
44 return validation.ValidateCollectionNSID(collection)
45}