schema

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateType

func ValidateType(v any) error

ValidateType validates a value if it implements Validatable

Types

type AlphaNumStr

type AlphaNumStr string

AlphaNumStr represents a string containing only letters and numbers

func (AlphaNumStr) Validate

func (a AlphaNumStr) Validate() error

Validate checks if the string contains only alphanumeric characters

type AlphaStr

type AlphaStr string

AlphaStr represents a string containing only letters

func (AlphaStr) Validate

func (a AlphaStr) Validate() error

Validate checks if the string contains only alphabetic characters

type AwareDateTime

type AwareDateTime time.Time

AwareDateTime represents a datetime with timezone information

func (AwareDateTime) Time

func (a AwareDateTime) Time() time.Time

Time returns the underlying time.Time

func (AwareDateTime) Validate

func (a AwareDateTime) Validate() error

Validate checks if the datetime has timezone info

type Base64Str

type Base64Str string

Base64Str represents a base64-encoded string

func (Base64Str) Validate

func (b Base64Str) Validate() error

Validate checks if the string is valid base64

type DirectoryPath

type DirectoryPath string

DirectoryPath represents a path to an existing directory

func (DirectoryPath) String

func (d DirectoryPath) String() string

String returns the directory path as a string

func (DirectoryPath) Validate

func (d DirectoryPath) Validate() error

Validate checks if the path points to an existing directory

type EmailStr

type EmailStr string

EmailStr represents a valid email address

func (EmailStr) String

func (e EmailStr) String() string

String returns the email as a string

func (EmailStr) Validate

func (e EmailStr) Validate() error

Validate checks if the string is a valid email

type FilePath

type FilePath string

FilePath represents a path to an existing file

func (FilePath) String

func (f FilePath) String() string

String returns the file path as a string

func (FilePath) Validate

func (f FilePath) Validate() error

Validate checks if the path points to an existing file

type FutureDate

type FutureDate time.Time

FutureDate represents a date that must be in the future

func (FutureDate) Time

func (f FutureDate) Time() time.Time

Time returns the underlying time.Time

func (FutureDate) Validate

func (f FutureDate) Validate() error

Validate checks if the date is in the future

type HexStr

type HexStr string

HexStr represents a hexadecimal string

func (HexStr) Validate

func (h HexStr) Validate() error

Validate checks if the string is valid hexadecimal

type HttpUrl

type HttpUrl string

HttpUrl represents a valid HTTP/HTTPS URL

func (HttpUrl) String

func (h HttpUrl) String() string

String returns the URL as a string

func (HttpUrl) Validate

func (h HttpUrl) Validate() error

Validate checks if the string is a valid HTTP(S) URL

type LowercaseStr

type LowercaseStr string

LowercaseStr represents a string that must be lowercase

func (LowercaseStr) Validate

func (l LowercaseStr) Validate() error

Validate checks if the string is lowercase

type NaiveDateTime

type NaiveDateTime time.Time

NaiveDateTime represents a datetime without timezone information

func (NaiveDateTime) Time

func (n NaiveDateTime) Time() time.Time

Time returns the underlying time.Time

func (NaiveDateTime) Validate

func (n NaiveDateTime) Validate() error

Validate checks if the datetime lacks timezone info

type NegativeFloat

type NegativeFloat float64

NegativeFloat represents a float64 < 0

func (NegativeFloat) Validate

func (n NegativeFloat) Validate() error

Validate checks if the value is negative

type NegativeInt

type NegativeInt int

NegativeInt represents an integer < 0

func (NegativeInt) Validate

func (n NegativeInt) Validate() error

Validate checks if the value is negative

type NonNegativeFloat

type NonNegativeFloat float64

NonNegativeFloat represents a float64 >= 0

func (NonNegativeFloat) Validate

func (n NonNegativeFloat) Validate() error

Validate checks if the value is non-negative

type NonNegativeInt

type NonNegativeInt int

NonNegativeInt represents an integer >= 0

func (NonNegativeInt) Validate

func (n NonNegativeInt) Validate() error

Validate checks if the value is non-negative

type NonPositiveFloat

type NonPositiveFloat float64

NonPositiveFloat represents a float64 <= 0

func (NonPositiveFloat) Validate

func (n NonPositiveFloat) Validate() error

Validate checks if the value is non-positive

type NonPositiveInt

type NonPositiveInt int

NonPositiveInt represents an integer <= 0

func (NonPositiveInt) Validate

func (n NonPositiveInt) Validate() error

Validate checks if the value is non-positive

type NumericStr

type NumericStr string

NumericStr represents a string containing only numbers

func (NumericStr) Validate

func (n NumericStr) Validate() error

Validate checks if the string contains only numeric characters

type PastDate

type PastDate time.Time

PastDate represents a date that must be in the past

func (PastDate) Time

func (p PastDate) Time() time.Time

Time returns the underlying time.Time

func (PastDate) Validate

func (p PastDate) Validate() error

Validate checks if the date is in the past

type PositiveFloat

type PositiveFloat float64

PositiveFloat represents a float64 greater than 0

func (PositiveFloat) Validate

func (p PositiveFloat) Validate() error

Validate checks if the value is positive

type PositiveInt

type PositiveInt int

PositiveInt represents an integer greater than 0

func (PositiveInt) Validate

func (p PositiveInt) Validate() error

Validate checks if the value is positive

type UUID

type UUID string

UUID type represents a valid UUID string

func (UUID) String

func (u UUID) String() string

String returns the UUID as a string

func (UUID) Validate

func (u UUID) Validate() error

Validate checks if the string is a valid UUID

type UppercaseStr

type UppercaseStr string

UppercaseStr represents a string that must be uppercase

func (UppercaseStr) Validate

func (u UppercaseStr) Validate() error

Validate checks if the string is uppercase

type Validatable

type Validatable interface {
	Validate() error
}

Validatable is an interface for types that can validate themselves

Jump to

Keyboard shortcuts

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