StringNode<T extends String> class
A fluent builder for validating String values.
Use this class via Checkit.string to compose validations in a readable, chained style.
Example:
final result = Checkit.string
.min(5)
.max(10)
.email()
.validateOnce('test@example.com');
if (!result.isValid) {
print(result.firstError);
}
- Inheritance
-
- Object
- ValidatorNode<
T, StringNode< T> > - StringNode
Constructors
- StringNode(ValidationContext _config)
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
alpha(
{String? error}) → StringNode< T> -
Validates that the string contains only alphabetic characters (
a-z,A-Z). -
alphanumeric(
{String? error}) → StringNode< T> - Validates that the string contains only letters and digits.
-
any(
List< Validator< validators, {String? error}) → StringNode<T> >T> -
inherited
-
build(
{ValidationContext? context}) → ValidatorSet< T> -
Finalizes the validator into a reusable set.
inherited
-
clone(
{ValidationContext? context}) → StringNode< T> -
Clones this node with an optional different context.
override
-
contains(
String data, {String? error}) → StringNode< T> -
Validates that the string contains the
datasubstring. -
custom(
bool validate(T value, ValidationContext context), {String error = ''}) → StringNode< T> -
Adds a custom validator using a function.
inherited
-
dateTime(
String format) → StringDateNode< String> - Returns a StringDateNode that validates a specific date format.
-
dateTimeAuto(
{String? preferredFormat}) → StringDateNode< String> - Tries to automatically infer the date format from input.
-
dateTimeIso(
) → StringDateNode< String> - Validates an ISO 8601 date-time string.
-
email(
{String? error}) → StringNode< T> - Validates that the string is a valid email address.
-
endsWith(
String suffix, {String? error}) → StringNode< T> -
Validates that the string ends with the specified
suffix. -
equals(
String expectedString, {String? error}) → StringNode< T> -
Validates that the string is exactly equal to
expectedString. -
every(
List< Validator< validators, {String? error}) → StringNode<T> >T> -
inherited
-
exact(
int length, {String? error}) → StringNode< T> -
Validates that the string has exactly
lengthcharacters. -
hasRepeats(
{String? error}) → StringNode< T> - Validates that the string contains repeating characters in a row.
-
hasSymbols(
String symbols, {String? error}) → StringNode< T> -
Validates that the string contains at least one of the provided
symbols. -
ip(
) → IpNode< String> - Switches to IP-specific validation rules.
-
isDouble(
{String? error}) → StringNode< T> - Validates that the string can be parsed into a double.
-
isInt(
{String? error}) → StringNode< T> - Validates that the string can be parsed into an integer.
-
jwt(
{String? error}) → StringNode< T> -
Validates that the string is a valid JWT token format (3 parts separated by
.). -
max(
int length, {String? error}) → StringNode< T> -
Validates that the string has no more than
lengthcharacters. -
min(
int length, {String? error}) → StringNode< T> -
Validates that the string has at least
lengthcharacters. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
not(
Validator< T> validator, {String? error}) → StringNode<T> -
Negates another validator.
inherited
-
password(
) → PasswordNode< String> - Returns a PasswordNode with password-specific validation rules.
-
pattern(
String pattern, {String? error}) → StringNode< T> -
Validates that the string matches the given regex
pattern. -
range(
int min, int max, {String? error, bool includeMin = true, bool includeMax = true}) → StringNode< T> - Validates that the string is within a specific range.
-
startsWith(
String suffix, {String? error}) → StringNode< T> -
Validates that the string starts with the specified
prefix. -
subnet(
String cidr) → SubnetNode< String> - Switches to subnet-specific validation rules using CIDR.
-
toString(
) → String -
A string representation of this object.
inherited
-
validateOnce(
T? value, {bool? stopOnFirstError}) → ValidationResult -
Quick validation without manually building the set.
inherited
-
withContext(
ValidationContext context) → StringNode< T> -
Shortcut to clone with updated context.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited