Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notBlank validator #70

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions glade_forms/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## DEV:
- **[Add]**: Add `allowBlank` parameter to `isEmpty` string validator.
- **[Add]**: Add `IntInput` as a specialized variant of GladeInput<int> which has additional, int related, validations such as `isBetween`, `isMin`, `isMax`
- **[Add]**: Support skipping particular validation with `shouldValidate` callback.
- **[Breaking]**: The `resetToPure` method on both GladeInput and GladeModel has been renamed to `setAsNewPure`. This change better reflects the method's behavior of setting a new pure state rather than resetting to the original state.
Expand Down
3 changes: 2 additions & 1 deletion glade_forms/lib/src/validator/string_validator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ class StringValidator extends GladeValidator<String> {
OnValidateError<String>? devError,
Object? key,
ShouldValidateCallback<String>? shouldValidate,
bool allowBlank = true,
}) =>
satisfy(
(input) => input.isNotEmpty,
(input) => allowBlank ? input.isNotEmpty : input.trim().isNotEmpty,
devError: devError ?? (_) => "Value can't be empty",
key: key ?? GladeErrorKeys.stringEmpty,
shouldValidate: shouldValidate,
Expand Down