Skip to content

Commit

Permalink
Add notBlank validator
Browse files Browse the repository at this point in the history
  • Loading branch information
petr-jilek committed Oct 8, 2024
1 parent df5fd2e commit ff062f1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions glade_forms/lib/src/validator/string_validator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ class StringValidator extends GladeValidator<String> {
shouldValidate: shouldValidate,
);

/// Given value can't be blank.
void notBlank({
OnValidateError<String>? devError,
Object? key,
ShouldValidateCallback<String>? shouldValidate,
}) =>
satisfy(
(input) => input.trim().isNotEmpty,
devError: devError ?? (_) => "Value can't be empty",
key: key ?? GladeErrorKeys.stringEmpty,
shouldValidate: shouldValidate,
);

/// Checks that value is valid email address.
///
/// Used Regex expression `^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$`.
Expand Down

0 comments on commit ff062f1

Please sign in to comment.