-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af6d4c9
commit 4774755
Showing
10 changed files
with
232 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Changelog | ||
|
||
## [Unreleased] | ||
|
||
### Fixed | ||
- **ProfanityResolver**: Updated the `errors` object structure in `ProfanityResolver` to align with expected test output. | ||
- Previously, the error messages included an unnecessary nested object structure with both `isValid` and `message` properties. | ||
- Now, only the `message` string is returned in `errors` when profanity is detected, following the format `{ type: "profanity", message: "Content flagged for: badword" }`. | ||
|
||
### Changed | ||
- **Validation Logic**: The `ProfanityResolver` was modified to: | ||
- Store only the `message` string for profane fields, improving compatibility with expected test cases. | ||
- Populate `errors` directly with the `message` string and `type`, instead of the full result object with `isValid` status. | ||
- Ensure `validFields` and `errors` correctly separate valid and invalid fields based on profanity checks. | ||
|
||
### Testing | ||
- **Updated Tests**: Adjusted test cases to validate the refined `errors` object structure, ensuring that the resolved errors output matches expectations. | ||
|
||
--- | ||
|
||
**Note:** This change does not impact the overall functionality of `ProfanityResolver` but improves consistency in output format for better test compatibility. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# profanity-validator | ||
|
||
A lightweight SDK for profanity filtering in forms. This library is designed to prevent bad word spam by validating user input and throwing errors if profanity is detected. Built to be flexible, it can be integrated easily into any HTML or JavaScript framework, including React, Next.js, and many more. | ||
|
||
## Features | ||
|
||
- **Profanity Filtering:** Automatically detects and validates user input against a predefined list of profane words. | ||
- **Customizable:** Allows users to add their own custom profanity words to the validation. | ||
- **Framework Agnostic:** Works seamlessly across different frameworks and libraries. | ||
- **Error Handling:** Throws validation errors instead of replacing profanity words, preventing form submission. | ||
- **Asynchronous Validation:** Uses an internal API [(profanity.dev)](https://www.profanity.dev/) to check for profanity, Built by [Josh](https://github.com/joschan21) . | ||
|
||
## Installation | ||
|
||
You can install the SDK via any nodejs package manager: | ||
|
||
```bash | ||
npm install profanity-validator | ||
pnpm add profanity-validator | ||
bun add profanity-validator | ||
yarn add profanity-validator | ||
``` | ||
|
||
## Contributing | ||
|
||
We welcome contributions! Please feel free to submit a pull request or open an issue if you have suggestions or improvements. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License. See the [LICENSE](https://github.com/SkidGod4444/profanity-validator?tab=MIT-1-ov-file) file for details. | ||
|
||
## Contact | ||
|
||
For support or inquiries, please reach out to [connect.saidev@gmail.com](https://dub.sh/saidev-twitter) or join our [discord community!](https://l.devwtf.in/discord) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.