Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CronExpression ¶
CronExpression validates a cron expression.
It only supports 5 fields (minute, hour, day of month, month, day of week).
It returns a boolean indicating whether the expression is valid or not.
func Email ¶
Email validates an email address. It returns a boolean indicating whether the email is valid or not.
func JSON ¶
JSON validates a JSON string, it returns a boolean indicating whether the JSON is valid or not.
func ListenHost ¶
ListenHost validates if addr is a valid host to listen on.
func PathPrefix ¶ added in v0.5.1
PathPrefix validates that a path prefix is correctly formatted.
Valid path prefixes: - Empty string (no prefix) - Must start with / - Must NOT end with / - No whitespace allowed
Examples: - "" -> true (no prefix) - "/api" -> true - "/pgbackweb" -> true - "/app/v1" -> true - "api" -> false (doesn't start with /) - "/api/" -> false (ends with /) - "/ api" -> false (contains whitespace)
Types ¶
type StructError ¶
type StructError struct {
// contains filtered or unexported fields
}
StructError is the error returned by Struct.
func Struct ¶
func Struct[T any](sPointer *T) *StructError
Struct validates the given struct using go-playground/validator.
func StructSlice ¶
func StructSlice[T any](sPointerSlice *[]T) *StructError
StructSlice validates the given slice of structs using go-playground/validator.
func (*StructError) Error ¶
func (e *StructError) Error() string
Error returns all the errors as a string separated by commas.
func (*StructError) Errors ¶
func (e *StructError) Errors() []string
Errors returns all the errors as a slice of strings.
func (*StructError) ErrorsRaw ¶
func (e *StructError) ErrorsRaw() []error
ErrorsRaw returns all the errors as a slice of errors.
func (*StructError) HasErrs ¶
func (e *StructError) HasErrs() bool
HasErrs returns true if there are errors.