You may filter quickly your strings in a couple steps. You can check is provided string is valid ? or you can simply replace bad word with given character.(You can use swear words list only for English language for now.)
You can import related functions as follows;
import { checkIsValid, replaceWordWith } from 'badword-filter';
This function takes two args and returns boolean as validation result.
You can use swear words list only for English language for now.
const ValidationOptions: object = {
swear: boolean,
negative: boolean,
political: boolean,
religions: boolean,
};
checkIsValid('word', ValidationOptions);
Parameter | Type | Description |
---|---|---|
data |
string |
Required. Your string to validate. |
ValidationOptions |
object |
Required. Your wished badword list types. |
This function takes three args and returns masked string with given pattern as validation result.
You can use swear words list only for English language for now.
const ValidationOptions: object = {
swear: boolean,
negative: boolean,
political: boolean,
religions: boolean,
};
replaceWordWith('word', '*', ValidationOptions);
Parameter | Type | Description |
---|---|---|
data |
string |
Required. Your string to validate. |
replacementCharacter |
string |
Required. Your special character using as replacer. |
ValidationOptions |
object |
Required. Your wished badword list types. |