Validation Rules
Flux ensures that the data you receive is clean, consistent, and correct before it ever reaches your notification channels. Validation rules are defined per-field directly in the Form Builder.
How it Works
Flux employs a dual-layer validation strategy to ensure both a smooth user experience and strict data integrity.
- Client-Side (HTML5):
Basic rules (liketype="email",required, ormaxlength) are rendered directly into the HTML. This provides immediate feedback to the browser, preventing the user from submitting obviously invalid forms. - Server-Side (Go):
Once submitted, Flux strictly validates every field against your configured rules in the backend. This is the security layer that prevents malicious users from bypassing client-side checks. - Error Handling:
If validation fails, Flux returns the form HTML (via HTMX) with error messages injected inline next to the problematic fields. Crucially, the user's input is preserved, so they never have to re-type their data.
Validation Rules
You can mix and match rules depending on the type of field you are configuring.
Global Rules (All Fields)
- Required: Marks the field as mandatory. The form cannot be submitted if this is empty.
- Default Error: "This field is required."
Text & Textarea
- Min Length: Enforce a minimum character count.
- Max Length: Enforce a maximum character count.
- Regex: Validate the input against a custom Regular Expression pattern.
- Example: Use
^[A-Z0-9]+$to ensure an input contains only uppercase letters and numbers.
- Example: Use
- Block Domains: A comma-separated list of domains to reject.
- Use Case: Useful for B2B forms where you want to block generic providers like
gmail.comoryahoo.comto force users to enter their business email address.
- Use Case: Useful for B2B forms where you want to block generic providers like
- Regex: Enforce custom email patterns if standard validation is insufficient.
Numbers
- Min Value: The lowest allowed number.
- Max Value: The highest allowed number.
Custom Error Messages
For every validation rule, you can define a Custom Error Message in the TUI. This allows you to speak your users' language (localization) or provide helpful hints.
- Default Behavior: Flux generates a generic message (e.g., "must be at least 5 characters").
- Custom Behavior: You can override this with something friendlier (e.g., "Your username is too short! Please pick a name with at least 5 characters.").
Configuring Validation
- SSH into your Flux instance:
- Navigate to Forms -> (Select Form) -> Manage Fields.
- Select an existing field to edit (or press
nto add a new one). - Navigate to the Validations section in the configuration wizard.
- Enter your constraints (e.g., type
10for Min Length). - (Optional) Enter a custom error message for that rule.
- Select Save.