TextValidationConfig class final

Configuration rules for valid text strings.

Provides constraints such as length limit, regular expression patterns, and blacklisted words.

Annotations
  • @immutable

Constructors

TextValidationConfig({int? minLength, int? maxLength, bool allowEmpty = false, bool allowOnlyWhitespace = false, bool trimWhitespace = true, String? pattern, Set<String> blacklistedWords = const {}, String? allowedCharacters, bool wholeWordBlacklist = false})
Creates a new TextValidationConfig with customizable rules.
const
TextValidationConfig.alphanumeric()
Alphanumeric only
factory
TextValidationConfig.longText()
Long text (articles, posts)
factory
TextValidationConfig.mediumText()
Medium text (descriptions, comments)
factory
TextValidationConfig.name()
Name validation (first name, last name)
factory
TextValidationConfig.shortText()
Short text (titles, labels)
factory
TextValidationConfig.username()
Username validation
factory

Properties

allowedCharacters → String?
Additional specification of characters that are allowed, often paired with pattern.
final
allowEmpty → bool
Whether empty text (or whitespace-only if not trimmed) is permitted.
final
allowOnlyWhitespace → bool
Whether text consisting solely of whitespace characters is permitted.
final
blacklistedWords → Set<String>
A set of words that are not permitted to appear in the text.
final
hashCode → int
The hash code for this object.
no setteroverride
maxLength → int?
Optional maximum allowable length.
final
minLength → int?
Optional minimum allowable length.
final
pattern → String?
A regular expression pattern that the text must match.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
trimWhitespace → bool
Whether the text should be trimmed (removing leading/trailing whitespace).
final
wholeWordBlacklist → bool
Whether blacklistedWords must match whole words only.
final

Methods

copyWith({Object? minLength = _unset, Object? maxLength = _unset, bool? allowEmpty, bool? allowOnlyWhitespace, bool? trimWhitespace, Object? pattern = _unset, Set<String>? blacklistedWords, Object? allowedCharacters = _unset, bool? wholeWordBlacklist}) → TextValidationConfig
Returns a copy of this config with the given fields replaced.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
override