Example 1: Basic Profanity Validation
This example demonstrates a basic profanity validation form.
It allows users to input text and checks it against a predefined array of profane words i.e ["badword", "inappropriate", "submit"] .
If any profanity is detected, it will alert the user.
Example 2: Profanity Validation with React Hook Form
To integrate profanity validation with React Hook Form,
this example uses a custom Profanity class to validate fields like "title," "description," and "tags" for inappropriate language on form submission,
setting errors as needed and allowing submission only if all fields pass validation.
Example 3: Integrating with Zod schema validation
To integrate with React Hook Form and Zod for a profanity-validated form.
It uses a custom Profanity validator to check fields like "title," "description," and "tags" for inappropriate language,
setting "custom errors" through Zod if profanity is detected.
Example 4: Multiple fields and real-time validation
This example demonstrates a dynamic form using ShadCN UI, where fields can be added or removed
and are validated for profanity in real-time with debouncing. A custom Profanity class checks each field's
content for inappropriate language, displaying error messages if any are detected.
The form highlights fields with profanity and allows users to address issues before submitting,
with notifications for both successful and failed submissions.