CommentValidator class
Validator for comment content.
Validates comment text for:
- Empty content
- Maximum length and line count
- Dangerous content (XSS, SQL injection, etc.)
- Bad words (configurable list)
Example:
final validator = CommentValidator(
badWordsData: 'bad\nword\ntest',
);
final error = await validator.validate('This is a comment', localizations);
if (error != null) {
// Show error to user
}
Constructors
- CommentValidator({required String badWordsData})
- Creates a new CommentValidator.
Properties
- badWordsData → String
-
The bad words data as a newline-separated string.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
censorBadWords(
String input) → Future< String> - Censors bad words in the input by replacing them with asterisks.
-
containsBadWords(
String input) → Future< bool> - Checks if the input contains any bad words.
-
containsDangerousContent(
String input) → bool - Checks if the input contains dangerous content.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
validate(
String text, CdxCommentsLocalizations loc, {int maxLines = 10, int maxLength = 400}) → Future< String?> - Validates comment text according to all rules.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited