Documentation
¶
Overview ¶
templ: version: v0.3.977
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
func Handler(fn ValidateFunc) http.HandlerFunc
Handler returns an http.HandlerFunc for a single ValidateFunc. The component ID is passed as a query parameter "id".
Mount each validator at its own path:
r.Get("/api/validate/email", validator.Handler(emailValidator))
r.Get("/api/validate/phone", validator.Handler(phoneValidator))
The component references this path via the ValidateURL prop.
func Input ¶
func Input(props InputProps) templ.Component
Input renders a DaisyUI input with server-side validation via Datastar. On input change (debounced), it calls the backend validator and shows/hides a validation hint based on the result.
func SuccessHint ¶
SuccessHint renders a hint that is visible only when validation succeeds and the input has a non-empty value.
Types ¶
type InputProps ¶
type InputProps struct {
// ID uniquely identifies this validator instance. Required.
ID string
// Class adds additional CSS classes to the input element.
Class string
// Attributes adds arbitrary HTML attributes to the input element.
Attributes templ.Attributes
// Type is the HTML input type. Defaults to TypeText.
Type InputType
// Name is the form field name attribute.
Name string
// Placeholder is the input placeholder text.
Placeholder string
// Value is the initial input value.
Value string
// ValidateURL is the endpoint path for server-side validation.
// The component appends "?id=<ID>" automatically.
// Example: "/api/validate/email"
ValidateURL string
// DebounceMs is the debounce delay in milliseconds. Defaults to 500.
DebounceMs int
// HintText is the error hint shown when validation fails.
// If empty, the backend error message is used.
HintText string
}
InputProps configures a validated input field.
type ValidateFunc ¶
ValidateFunc validates a string value and returns a Result.
Click to show internal directories.
Click to hide internal directories.